This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author amaury.forgeotdarc
Recipients amaury.forgeotdarc, swarecki
Date 2008-03-04.22:21:49
SpamBayes Score 0.00023784995
Marked as misclassified No
Message-id <1204669310.46.0.567425308522.issue2237@psf.upfronthosting.co.za>
In-reply-to
Content
> ... adding a line to end the code AFFECTS its beginning ...

Exactly. Please see
http://docs.python.org/dev/reference/executionmodel.html
"""
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.
"""

For more general discussions, see also:
http://www.python.org/doc/faq/programming/#what-are-the-rules-for-local-and-global-variables-in-python
http://docs.python.org/dev/tutorial/classes.html#python-scopes-and-name-spaces

In other words, this is one of the key features of the python language,
and I don't see how it could change.
History
Date User Action Args
2008-03-04 22:21:50amaury.forgeotdarcsetspambayes_score: 0.00023785 -> 0.00023784995
recipients: + amaury.forgeotdarc, swarecki
2008-03-04 22:21:50amaury.forgeotdarcsetspambayes_score: 0.00023785 -> 0.00023785
messageid: <1204669310.46.0.567425308522.issue2237@psf.upfronthosting.co.za>
2008-03-04 22:21:49amaury.forgeotdarclinkissue2237 messages
2008-03-04 22:21:49amaury.forgeotdarccreate