Nested scopes and class variables

wittempj at hotmail.com wittempj at hotmail.com
Mon Jan 31 03:58:42 EST 2005


To me it seems you should do it something like this:
-def f(x):
-    class C(object):
-        def __init__(self, x):
-            self.x = x # here you set the attribute for class C
-    c = C(x) # instantiate a C object
-    print c.x

-f(5)




More information about the Python-list mailing list