feature wish
Dan Parisien
dan at eevolved.com
Fri Mar 2 11:35:48 EST 2001
it seems all the special purpose overloadable methods are to provide type
emulation through classes
e.g.
__nonzero__
__contains__
__setitem__
etc.
it would be cool if there was another method provided that allowed a
programmer to overload the value returned by an instance as well.
e.g.
class example:
def __init__(self, name, data):
self.name = name
self.data = data
def __value__(self):
return self.data
eg = example("my name", (1,2,3))
>>>print eg
(1,2,3)
You could get to the instance behind the value by using a function like
instance(eg)
What do you guys think?
Dan
More information about the Python-list
mailing list