Make instance global -- possbile?

erokar at gmail.com erokar at gmail.com
Mon Mar 5 17:00:24 EST 2007


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?




More information about the Python-list mailing list