Class Variable Access and Assignment
Antoon Pardon
apardon at forel.vub.ac.be
Mon Nov 7 04:06:35 EST 2005
Op 2005-11-04, Steven D'Aprano schreef <steve at REMOVETHIScyber.com.au>:
> On Fri, 04 Nov 2005 10:48:54 +0000, Antoon Pardon wrote:
>
>> Please explain why this is illegal.
>>
>> x = 1
>> def f():
>> x += 1
>
> Because names in function namespaces don't have inheritance.
Your quibling about words. This certainly works.
x = 1
def f():
a = x + 1
So you could say that function namespaces do inherit from
outer scopes.
Whether you want to name it inheritance or not, is not the
issue.
--
Antoon Pardon
More information about the Python-list
mailing list