On 14/02/2013 at 09:29, xxxxxxxx wrote:
Hi,
I have got a stupid question I guess. It is actually not really c4d related, but I am asking here
anyway. I have got a quite simple node token class. It basically just stores instances of its own
type.
class rhTreeToken(object) :
def __init__(self, tokentype, children = None, subtype = None, value = None) :
if children == None:
self.Children = []
else:
self.Children = children
self.Subtype = subtype
self.Type = tokentype
self.Value = value
...
When I write the same fragment this way,
class rhTreeToken(object) :
def __init__(self, tokentype, children = [], subtype = None, value = None) :
or
def __init__(self, tokentype, children = list(), subtype = None, value = None) :
...
my whole node structure virtually explodes. I get an infinite recursion, data from other nodes
appear as children of nodes they were never assigned to, the whole class seems to share the
memory for rhTreeToken.Children then.
I suspect the optional arguments are not actually attached to the specific class instance, but
stored somewhere in Pyhton, so that the empty list would be shared by all instances. But i could
not find any proof / explanation for that, is that correct ?
thanks for reading,
a pretty confused,
ferdinand