[Python-Dev] Constructor bug

Nick Coghlan ncoghlan at iinet.net.au
Mon Nov 22 10:18:20 CET 2004

Oliver Walczak wrote:
> So, is it a bug or a feature? In my eyes this behaviour is not what the
> programmer has got to expect. Who knows whats happening there and can
> explain me if it makes any sense?

The output is exactly what I expected:

c1, before:
d1= {'key': 'value'}
d2= {'key': 'value'}
c1, after:
d1= {'key': 'value2'}
d2= {'key': 'value2'}
d1= {'key': 'value2'}
d2= {'key': 'value'}

Exactly what do you believe is mysterious here? c2 sees the modified version of 
the class variable (d1), and sees a fresh copy of the instance variable (d2).

Please make you question more explicit.


Nick Coghlan               |     Brisbane, Australia
Email: ncoghlan at email.com  | Mobile: +61 409 573 268

More information about the Python-Dev mailing list