property getter with more than 1 argument?

mk mrkafk at
Thu Jul 17 16:57:08 CEST 2008

It seems like getter is defined in such way that it passes only 'self':

class FunDict(dict):
	def __init__(self):
		self.fundict = dict()

	def fget(self, fun):
		return fundict[fun.func_name]

	def fset(self, newfun):
		self.fundict[newfun.func_name] = newfun

	newfun = property (fget, fset)

 >>> a=FunDict()
 >>> a.newfun=f1
 >>> a.newfun('f1')

Traceback (most recent call last):
   File "<pyshell#67>", line 1, in <module>
TypeError: fget() takes exactly 2 arguments (1 given)

Is it possible to pass more than one argument to fget function?

I know: I can define a function with property name ('newfun' in the 
example) and call it with more arguments. But then I do not get the 
benefits of setter and property in general!

More information about the Python-list mailing list