Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #38321
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2013-02-06 16:45 -0800 |
| References | <15fe7153-a77a-49eb-9cf8-d4e59b4a2079@z9g2000vbx.googlegroups.com> <mailman.1401.1360127082.2939.python-list@python.org> <5db4add7-ab9c-4311-b3b6-24156cd6f248@z4g2000vbz.googlegroups.com> <5112EF48.6040404@gmail.com> <mailman.1433.1360196074.2939.python-list@python.org> |
| Message-ID | <ef7640df-034a-4c20-a58a-53117c6f4a56@cd3g2000vbb.googlegroups.com> (permalink) |
| Subject | Re: best way to share an instance of a class among modules? |
| From | CM <cmpython@gmail.com> |
I was using self correctly, I think; but I should have said that the
code in the importing module would be within a class, so self there
refers to that class. But that's a side point.
I agree that utilities.shared_cursor is visible within the importing
module. But the problem below remains for me...
> > My only problem, then, is I create the shared_cursor from within a
> > function within the instance of DatabaseAccess(). How then do I pass
> > it from within the function's namespace to the module's namespace so
> > that I can do that first line?
> 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."
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?
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
best way to share an instance of a class among modules? CM <cmpython@gmail.com> - 2013-02-05 20:40 -0800
Re: best way to share an instance of a class among modules? Terry Reedy <tjreedy@udel.edu> - 2013-02-06 00:04 -0500
Re: best way to share an instance of a class among modules? CM <cmpython@gmail.com> - 2013-02-06 14:41 -0800
Re: best way to share an instance of a class among modules? Michael Torrie <torriem@gmail.com> - 2013-02-06 17:03 -0700
Re: best way to share an instance of a class among modules? c <chaelon@gmail.com> - 2013-02-06 16:43 -0800
Re: best way to share an instance of a class among modules? Ethan Furman <ethan@stoneleaf.us> - 2013-02-06 16:57 -0800
Re: best way to share an instance of a class among modules? Ethan Furman <ethan@stoneleaf.us> - 2013-02-06 17:36 -0800
Re: best way to share an instance of a class among modules? Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-07 18:14 -0800
Re: best way to share an instance of a class among modules? Michael Torrie <torriem@gmail.com> - 2013-02-07 23:05 -0700
Re: best way to share an instance of a class among modules? Michael Torrie <torriem@gmail.com> - 2013-02-08 21:54 -0700
Re: best way to share an instance of a class among modules? Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-07 18:14 -0800
Re: best way to share an instance of a class among modules? Michael Torrie <torriem@gmail.com> - 2013-02-06 17:14 -0700
Re: best way to share an instance of a class among modules? CM <cmpython@gmail.com> - 2013-02-06 16:45 -0800
Re: best way to share an instance of a class among modules? Michael Torrie <torriem@gmail.com> - 2013-02-06 18:08 -0700
csiph-web