I want this code
class Letter(object):
def __init__(self,l):
self.l = l
def __new__(cls,*args,**kw):
if hasattr(Letter,"L"):
return Letter.L
Letter.L = object.__new__(cls,"K",**kw)
return Letter.L
f1 = Letter("4")
print "f1 value was",f1.l
f2 = Letter("48")
print "Although I didn't change anything in f1, its value is now",f1.l
print f1 is f2
>> chaouche@karabeela ~/CODE/TEST/PYTHON $ python singleton.py
>> f1 value was 4
>> Although I didn't change anything in f1, its value is now 48
>> True
>> chaouche@karabeela ~/CODE/TEST/PYTHON $
to print two times "K" instead of "4","48", without changing the lines
f1 = Letter("4")
and
f1 = Letter("48")
Is it possible ?