Hi !
I want to create a property that can use parameter(s).
In Delphi I can create same thing (exm: Canvas.Pixel[x,y] ->
Canvas.GetPixel (self,X,Y):inte ger; Canvas.SetPixel (self,X,Y,Color ::integer);
class A(object):
def __init__(self):
self.__Tags={}
def GetTag(self,tna me):
return self.__Tags.get (tname,None)
def SetTag(self,tna me,value):
self.__Tags[tname]=Value
Tag=property(Ge tTag,SetTag)
a=A()
print a.Tag('A')
print a.Tag['A']
But it is seems to be not possible in this way.
How to be can ?
Thanx for help !
KK
I want to create a property that can use parameter(s).
In Delphi I can create same thing (exm: Canvas.Pixel[x,y] ->
Canvas.GetPixel (self,X,Y):inte ger; Canvas.SetPixel (self,X,Y,Color ::integer);
class A(object):
def __init__(self):
self.__Tags={}
def GetTag(self,tna me):
return self.__Tags.get (tname,None)
def SetTag(self,tna me,value):
self.__Tags[tname]=Value
Tag=property(Ge tTag,SetTag)
a=A()
print a.Tag('A')
print a.Tag['A']
But it is seems to be not possible in this way.
How to be can ?
Thanx for help !
KK
Comment