which a is used?
Thomas Rachel
nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at spamschutz.glglgl.de
Tue Sep 25 01:06:28 EDT 2012
Am 25.09.2012 03:47 schrieb Dwight Hutto:
> But within a class this is could be defined as self.x within the
> functions and changed, correct?
>
>
> class a():
> def __init__(self,a):
> self.a = a
>
> def f(self):
> print self.a
>
> def g(self):
> self.a = 20
> print self.a
>
>
> a = a(1)
> a.f()
> a.g()
Yes - this is a different situation. Here, the "self" referred to is the
same in all cases (the "a" from top level), and so self.a can be used
consistently as well.
Thomas
More information about the Python-list
mailing list