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


Groups > comp.lang.python > #50750

Re: Is this a bug?

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ian.g.kelly@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.015
X-Spam-Evidence '*H*': 0.97; '*S*': 0.00; '16,': 0.03; '"""': 0.07; 'subject:bug': 0.07; 'variables': 0.07; 'arguments': 0.09; 'python': 0.11; 'ah,': 0.16; 'assignments': 0.16; 'block.': 0.16; 'bound.': 0.16; 'declarations': 0.16; 'naming': 0.16; 'subtle.': 0.16; 'variable.': 0.16; 'applies': 0.16; 'language': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'normally': 0.19; 'appears': 0.22; 'case.': 0.24; "i've": 0.25; 'references': 0.26; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'function': 0.29; 'chris': 0.29; 'am,': 0.29; 'properties': 0.29; 'errors': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'block,': 0.31; 'occurs': 0.31; 'operations.': 0.31; 'allows': 0.31; 'class': 0.32; 'text': 0.33; 'url:python': 0.33; 'sense': 0.34; 'anywhere': 0.35; 'operations': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'url:org': 0.36; 'thank': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'how': 0.40; 'url:3': 0.61; 'entire': 0.61; 'name': 0.63; 'refer': 0.63; 'more': 0.64; 'occur': 0.65; 'within': 0.65; 'believe': 0.68; 'default': 0.69; 'jul': 0.74; 'behavior': 0.77; 'subject:this': 0.83; 'dict.': 0.84; 'url:reference': 0.84; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=W+e8iA6TbG7o5gf0Knz1Gk7ar1Yg72lV2NhwGrPFJDA=; b=YbL8ZZmZhRHjV1uBKH/Snxs7oSHcgog1eaLk4A7IT9c8XjXaQ9UBccfWC9X84CdKdM 9WSCJ4e8/xSCDddYxwLypzdNMqcIxO0U5sAzHFjHu+X+rtdgOp7ZYtggrR1azSdP4k8K OKsFQRdRpEAFhmvp+ICGOMOOFg6BxqEbA3k+CCZEdvgzAKzgxGCvsZrG9lq/zzIOigbA oaZCfa4Ob4tm+Z2bvtR7eWsa9GgcQAiEGGLW4IzLF8Cb0lDgT/IMo0XY+TtvudnsUBm7 cqHayERERpaV+N7jKAZxLSrvF6PYlOYS8ASIuHrhK/GEaof+ZP8ZAzjwSRMKf0ZsGW4q A1TQ==
X-Received by 10.68.138.170 with SMTP id qr10mr2644588pbb.158.1373997910880; Tue, 16 Jul 2013 11:05:10 -0700 (PDT)
MIME-Version 1.0
In-Reply-To <51E565EF.30602@nottheoilrig.com>
References <51E41A5C.7060903@nottheoilrig.com> <CAN1F8qUdqhkdROy22PBM+1Tq8Mxyg3PbbrdAQY1XOjXv7yF+QA@mail.gmail.com> <51E565EF.30602@nottheoilrig.com>
From Ian Kelly <ian.g.kelly@gmail.com>
Date Tue, 16 Jul 2013 12:04:30 -0600
Subject Re: Is this a bug?
To Python <python-list@python.org>
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
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.4777.1373997920.3114.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1373997920 news.xs4all.nl 15975 [2001:888:2000:d::a6]:39993
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:50750

Show key headers only | View raw


On Tue, Jul 16, 2013 at 9:25 AM, Jack Bates <tdhfwh@nottheoilrig.com> wrote:
> Ah, thank you Chris Angelico for explaining how this is like what happens
> with default arguments to a function and Joshua Landau for pointing out how
> assignments inside class bodies refer to properties of "self" on the LHS. It
> makes sense now. Only I'm struggling to find where the behavior is defined
> in the language reference. Can someone please help point me to where in the
> language reference this is discussed? I've been hunting through the section
> on naming and binding:
>
> http://docs.python.org/3/reference/executionmodel.html#naming-and-binding

The documentation appears to be wrong.  It says:

"""
If a name binding operation occurs anywhere within a code block, all
uses of the name within the block are treated as references to the
current block. This can lead to errors when a name is used within a
block before it is bound. This rule is subtle. Python lacks
declarations and allows name binding operations to occur anywhere
within a code block. The local variables of a code block can be
determined by scanning the entire text of the block for name binding
operations.
"""

But this only applies to function blocks, not the general case.  In
general, I believe it is more accurate to say that a variable is local
to the block if its name is found in the locals() dict.  That normally
won't be true until the variable has been bound.  Any references prior
to that will look for a global variable.

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


Thread

Re: Is this a bug? Ian Kelly <ian.g.kelly@gmail.com> - 2013-07-16 12:04 -0600

csiph-web