En Sun, 25 Mar 2007 23:34:51 -0300, manstey <[EMAIL PROTECTED]> escribió:
> I've realised after further testing and reading that I actually need
> to do this:
>
dic_myinstances={}
class MyClass(object):
> def __new__(cls,id):
> global dic_myinstances
> if dic_myinstan
Hi, yet again to myself!
I've realised after further testing and reading that I actually need
to do this:
>>>dic_myinstances={}
>>>class MyClass(object):
def __new__(cls,id):
global dic_myinstances
if dic_myinstances.has_key(id):
return dic_myinstances[id]
Hi,
I solved it myself! I realised that __new__ creates self prior to
init, so this works:
>>>dic_myinstances={}
>>>class MyClass(object):
def __new__(self,id):
global dic_myinstances
if dic_myinstances.has_key(id):
return dic_myinstances[id]
else:
Hi,
I'm not sure why this doesn't work:
>>>dic_myinstances={}
>>>class MyClass(object):
def __init__(self, id):
global dic_myinstances
if dic_myinstances.has_key(id):
self = dic_myinstances[id]
else:
dic_myinstances[id] = self
>>>ins1 =