splitting common functions into a sepperate module
gagsl-py2 at yahoo.com.ar
Thu Mar 8 10:06:39 CET 2007
En Thu, 08 Mar 2007 05:45:24 -0300, <jonkersbart at gmail.com> escribió:
> I have wrote a script and want to group some functions of the script
> in a separate modulo so that I can import the module in other scripts
> and use the same functions there..
> The problem is that the common functions need access to some global
> variables defined in the script. Python uses different namespaces for
> different modules so I can't access the variables of the script in the
Are those *really* global variables? If yes, you could put them in yet
another module, maybe config.py, and always get/set them using:
config.xxx = "abc"
(do *not* use: from config import xxx)
Or, you may consider placing the global variables on the same module as
those common functions (if that make some sense...)
But perhaps they are not really global variables, and you can use some
class to hold them, specially if you can logically attach some methods to
Without further knowledge of the application, that's all I can say.
More information about the Python-list