Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #4555
| 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 | <dan.kluev@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'subject:module': 0.04; 'wed,': 0.04; 'int,': 0.07; 'foo': 0.09; 'namespace': 0.09; 'object.': 0.09; 'values,': 0.09; 'am,': 0.14; 'modify': 0.14; 'wrote:': 0.14; 'assigns': 0.16; 'cpython,': 0.16; 'did.': 0.16; 'immutable,': 0.16; 'namespace,': 0.16; 'namespace.': 0.16; 'set,': 0.16; 'subject:directly': 0.16; 'subject:those': 0.16; 'cc:no real name:2**0': 0.20; 'cc:2**0': 0.20; 'header:In-Reply- To:1': 0.22; 'cc:addr:python-list': 0.22; 'objects,': 0.23; 'received:209.85.214.174': 0.23; 'received:mail- iw0-f174.google.com': 0.23; '(in': 0.27; 'object': 0.27; 'message- id:@mail.gmail.com': 0.28; 'subject:?': 0.29; 'daniel': 0.29; 'cc:addr:python.org': 0.31; 'imported': 0.31; 'import': 0.32; 'module': 0.33; 'reference': 0.34; 'got': 0.34; 'point': 0.35; 'some': 0.37; 'received:209.85': 0.37; 'exactly': 0.37; 'references': 0.38; 'received:google.com': 0.38; 'but': 0.38; 'current': 0.38; 'received:209.85.214': 0.39; 'received:209': 0.39; 'header:Received:5': 0.40; 'best': 0.60; '2011': 0.62; 'hand,': 0.72; '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:cc:content-type; bh=AqSyytJ9QUDg7e6CCY2STV3WL1Zz5ro4dXbweXN4i5E=; b=FibaEKUNjgmRBWFtvKlx1cH9Fi/zDlZkdoKvaozoi5X8IigYke9d24OPN80eurepTy 9m/vBRAN4dZOq2WtDbfjLujmj/on45Jo5MyAmQ/gsUQYqSg4sXxNqXcjI3l704HcN069 SCIVyFKKzK1/PFc+syQ43N9w8EHrBonNZ4Gig= |
| 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 :cc:content-type; b=bY5udlA19T5mT2/5vaDaSc7WCpY3XLAVRPUMatzgnnoqbOZxtjux+QgP6pBIZDzNgm UFb8bepPa3ST9DKUvEW3L3G9rlMINDc6qjKdNWiliKaoN0z/OqBg7NNoSslHKI2/QbNZ oHHnduU1K7+JiwSkqgpxabreWM4EAZ6IR+Tzs= |
| MIME-Version | 1.0 |
| In-Reply-To | <d8d1d20e-2edd-49e5-917c-f338ef35006f@l18g2000yql.googlegroups.com> |
| References | <d8d1d20e-2edd-49e5-917c-f338ef35006f@l18g2000yql.googlegroups.com> |
| Date | Wed, 4 May 2011 03:57:51 +1100 |
| Subject | Re: Why do directly imported variables behave differently than those attached to imported module? |
| From | Daniel Kluev <dan.kluev@gmail.com> |
| To | Dun Peal <dunpealer@gmail.com> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Cc | python-list@python.org |
| 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.1115.1304441878.9059.python-list@python.org> (permalink) |
| Lines | 22 |
| NNTP-Posting-Host | 82.94.164.166 |
| X-Trace | 1304441879 news.xs4all.nl 81475 [::ffff:82.94.164.166]:50675 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:4555 |
Show key headers only | View raw
On Wed, May 4, 2011 at 3:31 AM, Dun Peal <dunpealer@gmail.com> wrote: > Apparently, the `var` we imported from `foo` never got set, but > `foo.var` on the imported `foo` - did. Why? Because all names are references to some values, not other names (in CPython, it means all names are PyObject*, and point directly to the objects, not other pointers) When you do `from foo import bar` it assigns globals()['bar'] of current module to reference same value as `foo.bar`. Its now local namespace name, not `foo` namespace, and therefore functions in `foo` cannot modify this namespace. Since ints are immutable, when you do `var = 1` you create new object of type int, and re-assign `var` name to point to new object. `foo.var`, on other hand, is a way to access `foo`'s own namespace, so its exactly same name as globals()['var'] of `foo`. -- With best regards, Daniel Kluev
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