On Feb 10, 2008, at 2:13 PM, Simon King wrote:

> {}. Moreover, a.Data and b.Data should be different objects, because
> "D={}" should create a *new* empty dictionary each time.

No -- this is incorrect. The new dictionary is created when the  
interpreter *reads the class definition*. It happens only once, not  
each time you call the constructor.

This is a common python "gotcha", and the standard python idiom to  
deal with this is:

def func(D=None):
        if D is None:
                D = {}
        [...]

david


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to