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: 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: References: 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 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On Wed, May 4, 2011 at 2:57 AM, Chris Rebert 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