Class Variable Access and Assignment
Antoon Pardon
apardon at forel.vub.ac.be
Thu Nov 3 09:30:40 EST 2005
Op 2005-11-03, venk schreef <venkatasubramanian at gmail.com>:
> hey,
> did u read my reply fully? i too feel that this matter of raising
> unbound local error in one case and not raising it in the other must be
> analysed...
Yes, it seems I didn't respond to your satisfaction, but since you
don't provide details I can't clarify.
> quoting from the documentation
> "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."
Well I wonder. Would the following code be considered a name binding
operation:
b.a = 5
--
Antoon Pardon
More information about the Python-list
mailing list