Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #4602
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!xlned.com!feeder1.xlned.com!news.netcologne.de!newsfeed-fusi2.netcologne.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Duncan Booth <duncan.booth@invalid.invalid> |
| Newsgroups | comp.lang.python |
| Subject | Re: Why do directly imported variables behave differently than those attached to imported module? |
| Date | 4 May 2011 08:44:36 GMT |
| Lines | 23 |
| Message-ID | <Xns9EDB630F1EB14duncanbooth@127.0.0.1> (permalink) |
| References | <d8d1d20e-2edd-49e5-917c-f338ef35006f@l18g2000yql.googlegroups.com> <BANLkTikT3qeeMAToUhO7GDrve5fAJ_+vFg@mail.gmail.com> <mailman.1123.1304459240.9059.python-list@python.org> |
| Reply-To | duncan.booth@suttoncourtenay.org.uk |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=iso-8859-1 |
| Content-Transfer-Encoding | 8bit |
| X-Trace | individual.net IqlReVtY5pUz9iJe0bANZwiWco1786ytwvJSuydDj1ER6OsxwG |
| Cancel-Lock | sha1:/rUtDcwApON4q1k4UZVnh0BZOcE= |
| User-Agent | Xnews/2006.08.24 Hamster/2.1.0.11 |
| X-Face | .C;/v3#w@2k.C(.1v-}d=`|7AQ-%,#A$0ZGtAkLPvuawAM>3#D,pXaAb31%(=Gn2ZZK/Z~fd0y4't5iKK~F":}F2*|\mQYX+BUr4ZM*|+`@o-TKzFGwsJnan{)*b~QJ-Fu^u'$$nYV |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:4602 |
Show key headers only | View raw
Chris Angelico <rosuav@gmail.com> wrote: > Here's a side point. What types will hold a reference to the enclosing > module (or at least its dictionary)? Would it be possible to use a > from import to load a module, then "lose" the module even though > you're using objects from it? > > I am guessing that a function or class will hold such a reference, > because otherwise it would be a bit awkward for them to use any sort > of module-level state. Or do they not, and instead go look for their > module in sys.modules? A function object has a reference to the dictionary for the module in which it was defined; it needs this to access global variables. A class holds the name of the module but has no reference to the actual module itself. Yes, it is quite possible to delete a module object, but it won't generally matter since any classes that are still referenced will prevent their methods being deleted and any functions or methods that are still accessible will keep the globals alive as long as required. -- Duncan Booth http://kupuguy.blogspot.com
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Why do directly imported variables behave differently than those attached to imported module? Dun Peal <dunpealer@gmail.com> - 2011-05-03 09:31 -0700
Re: Why do directly imported variables behave differently than those attached to imported module? Chris Rebert <clp2@rebertia.com> - 2011-05-03 09:57 -0700
Re: Why do directly imported variables behave differently than those attached to imported module? Daniel Kluev <dan.kluev@gmail.com> - 2011-05-04 03:57 +1100
Re: Why do directly imported variables behave differently than those attached to imported module? Mel <mwilson@the-wire.com> - 2011-05-03 13:00 -0400
Re: Why do directly imported variables behave differently than those attached to imported module? Terry Reedy <tjreedy@udel.edu> - 2011-05-03 13:13 -0400
Re: Why do directly imported variables behave differently than those attached to imported module? harrismh777 <harrismh777@charter.net> - 2011-05-03 12:24 -0500
Re: Why do directly imported variables behave differently than those attached to imported module? Dun Peal <dunpealer@gmail.com> - 2011-05-03 11:51 -0700
Re: Why do directly imported variables behave differently than those attached to imported module? Dun Peal <dunpealer@gmail.com> - 2011-05-03 12:23 -0700
Re: Why do directly imported variables behave differently than those attached to imported module? Daniel Kluev <dan.kluev@gmail.com> - 2011-05-04 06:55 +1100
Re: Why do directly imported variables behave differently than those attached to imported module? Chris Angelico <rosuav@gmail.com> - 2011-05-04 07:47 +1000
Re: Why do directly imported variables behave differently than those attached to imported module? Duncan Booth <duncan.booth@invalid.invalid> - 2011-05-04 08:44 +0000
Re: Why do directly imported variables behave differently than those attached to imported module? Chris Rebert <clp2@rebertia.com> - 2011-05-03 15:11 -0700
csiph-web