Property with parameter...

kepes.krisztian kepes.krisztian at peto.hu
Mon Sep 13 03:59:43 EDT 2004


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):integer; Canvas.SetPixel(self,X,Y,Color::integer);

class A(object):
      def __init__(self):
          self.__Tags={}
      def GetTag(self,tname):
          return self.__Tags.get(tname,None)
      def SetTag(self,tname,value):
          self.__Tags[tname]=Value
      Tag=property(GetTag,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





More information about the Python-list mailing list