let me simplify my question on scope of vars

Pyenos pyenos at pyenos.org
Fri Dec 22 19:57:44 EST 2006


"code"
var=1
class CLASS:
        def METHOD1:
                def METHOD2:
                        var+=var
                return var
                METHOD2()       #line8                   
        return var                            
METHOD1()                       #line10
"end code"

Q1: does class CLASS inherit var=0 from line1?
Q2: does def METHOD1 inherit var=0 from line1?
Q3: does def METHOD2 inherit var=0 from line1?
Q3: does line8 return '2'?
Q4: does line10 return '2\n2'?



More information about the Python-list mailing list