Global object

Steven Bethard steven.bethard at gmail.com
Wed Nov 22 17:45:21 EST 2006


Ghido wrote:
> Hi all, i need to save in an object some variable for use in  other
> parts of my software. it's possibile without create an istance of this
> class in every file? if yes how? 

Create a module, say, ``config``.  Then to save your object, you use 
something like::

     import config
     config.value = value_to_save

Now if you want to access it from other parts of your program, simply 
write::

     import config
     do_something_with(config.value)



STeVe



More information about the Python-list mailing list