Make instance global -- possbile?

Arnaud Delobelle arnodel at googlemail.com
Mon Mar 5 23:15:03 CET 2007


On Mar 5, 10:00 pm, ero... at gmail.com wrote:
> Rather new to OOP in Python...
>
> I'm writing an app where several objects need to access and change the
> state of ONE instance.
>
> I could of course instantiate the instance and then pass it along the
> objects, but that's cumbersome, especially as it would need to be
> "passed through" classes that don't really need it.
>
> I would be happy if I could just instantiate the object in the main
> module and declare it global, but classes are in different modules so
> I guess that won't work.
>
> Have looked a bit into singletons -- is that the way to go?

Put your 'global' stuff into a module and use import?

--
Arnaud




More information about the Python-list mailing list