best way to share an instance of a class among modules?

Michael Torrie torriem at
Thu Feb 7 01:14:27 CET 2013

On 02/06/2013 05:03 PM, Michael Torrie wrote:
> Every function in a module has access to the module's global namespace.
>  And your shared_cursor is there, inside of the utilities reference,
> since utilities was imported into your module, "importer."

Just to be clear:

import mod1

def testfunc1():
    print mod1.a

def testfunc2():
    mod1.a = 6

import mod1
import mod2



The program will print out "5" and "6."

If I understand your original question, this example will demonstrate
it.  But I could have understood wrong!

More information about the Python-list mailing list