python newbie - question about lexical scoping

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Sun Dec 2 15:59:21 EST 2007


Bruno Desthuilliers a écrit :
(snip)


> class Foo(object):
>   bar = {'baz':'bing'}
>   def __init__(self):
>     self.bar = self.bar

Hem... Should re-read before posting :(

It's of course:

    def __init__(self):
       self.bar = self.bar.copy()



More information about the Python-list mailing list