Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #4576

Re: Why do directly imported variables behave differently than those attached to imported module?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'subject:module': 0.04; 'wed,': 0.04; 'foo': 0.09; 'essentially': 0.12; 'am,': 0.14; 'wrote:': 0.14; 'doing:': 0.16; 'guessing': 0.16; 'rebert': 0.16; 'subject:directly': 0.16; 'subject:those': 0.16; '(or': 0.22; 'header:In-Reply-To:1': 0.22; 'module,': 0.23; 'received:209.85.214.174': 0.23; 'received:mail- iw0-f174.google.com': 0.23; 'objects': 0.24; 'instead': 0.26; 'chris': 0.27; 'function': 0.27; 'message-id:@mail.gmail.com': 0.28; 'load': 0.28; 'subject:?': 0.29; 'class': 0.29; 'sort': 0.30; 'least': 0.30; 'import': 0.32; 'to:addr:python-list': 0.32; 'bit': 0.33; 'module': 0.33; 'reference': 0.34; 'using': 0.34; 'it?': 0.37; 'received:209.85': 0.37; 'received:google.com': 0.38; 'though': 0.38; 'hold': 0.39; 'not,': 0.39; 'received:209.85.214': 0.39; 'set': 0.39; 'to:addr:python.org': 0.39; 'received:209': 0.39; 'would': 0.40; 'header:Received:5': 0.40; '2011': 0.62; 'var': 0.65; 'subject:Why': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=ZDbmZdHsBqlFEY9LcFRrlE4WBj7b0QnzApRo0LntAJ4=; b=DI1TPxhNE4GRo9SZFa1s7Yd+oqDENtI2nBeXh8Md98niPXWLb64KBQtU00S+c76iV0 w0RcDCKE9lkoC42EQOeP4SQv0muH5Zk05r/pm3HtWsWD3VcknRSE0BtNBOT7HSOrkm70 xPaIQfDk/0+e/S2iU2VYO4sNkQMwjRoixF74U=
DomainKey-Signature a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=OiAvmrm1jpyX4XyOYP1BASyTaM7AT6WG+TvJ5y5YMtLlkms7p3JOe4vU2F2T8dal9r cURmReINal8otbYEGYZI3UNi/lx2i3VJf6Jo26gbrSqdL1RUVPZYuasbu2QsN0aT3BsU 7Su29kiQfxC7jI6pW+B8JL3eRhhTUXnGUfS9k=
MIME-Version 1.0
In-Reply-To <BANLkTikT3qeeMAToUhO7GDrve5fAJ_+vFg@mail.gmail.com>
References <d8d1d20e-2edd-49e5-917c-f338ef35006f@l18g2000yql.googlegroups.com> <BANLkTikT3qeeMAToUhO7GDrve5fAJ_+vFg@mail.gmail.com>
Date Wed, 4 May 2011 07:47:17 +1000
Subject Re: Why do directly imported variables behave differently than those attached to imported module?
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1123.1304459240.9059.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 82.94.164.166
X-Trace 1304459241 news.xs4all.nl 81479 [::ffff:82.94.164.166]:53467
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:4576

Show key headers only | View raw


On Wed, May 4, 2011 at 2:57 AM, Chris Rebert <clp2@rebertia.com> wrote:
> from foo import *
>
> can be thought of as essentially doing:
>
> import foo
> set = foo.set
> var = foo.var
> del foo

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?

Chris Angelico

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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