best way to share an instance of a class among modules?
ethan at stoneleaf.us
Thu Feb 7 01:57:38 CET 2013
On 02/06/2013 04:43 PM, c wrote:
> But the function in the module is also within a *class* so I don't
> think the function does have access to the module's global namespace.
> Here's the hierarchy:
> -- Module namespace....
> ---- class namespace (DatabaseAccess is the name of the class)
> ---- function namespace
> This is where the cursor is created. How do I get it
> into the module namespace?
In the class namespace you have something like:
self.shared_cursor = ...
to get that into the module namespace instead, just remove the 'self':
shared_cursor = ...
More information about the Python-list