all although such cross-file variable changes are always possible in pythonthey are usually much more subtle than you will want againthis sets up too strong coupling between the two files--because they are both dependent on the value of the variable xit' difficult to understand or reuse one file without the other such implicit cross-file dependencies can lead to inflexible code at bestand outright bugs at worst here againthe best prescription is generally to not do this--the best way to communicate across file boundaries is to call functionspassing in arguments and getting back return values in this specific casewe would probably be better off coding an accessor function to manage the changefirst py def setx(new)global new second py import first first setx( accessor make external changes explit and can manage access in single place call the function instead of changing directly this requires more code and may seem like trivial changebut it makes huge difference in terms of readability and maintainability--when person reading the first module by itself sees functionthat person will know that it is point of interface and will expect the change to the in other wordsit removes the element of surprise that is rarely good thing in software projects although we cannot prevent cross-file changes from happeningcommon sense dictates that they should be minimized unless widely accepted across the program when we meet classes in part viwe'll see similar techniques for coding attribute accessors unlike modulesclasses can also intercept attribute fetches automatically with operator overloadingeven when accessors aren' used by their clients other ways to access globals interestinglybecause global-scope variables morph into the attributes of loaded module objectwe can emulate the global statement by importing the enclosing module and assigning to its attributesas in the following example module file code in this file imports the enclosing modulefirst by nameand then by indexing the sys modules loaded modules table (more on this table in and )thismod py var scopes global variable =module attribute