Is __mul__ sufficient for operator '*'?
Mick Krippendorf
mad.mick at gmx.de
Mon Oct 19 23:59:12 EDT 2009
Gabriel Genellina schrieb:
> __special__ methods are searched in the type, not in the instance
> directly. x*y looks for type(x).__mul__ (among other things)
So I thought too, but:
class meta(type):
def __mul__(*args):
return 123
class boo(object):
__metaclass__ = meta
print boo.__mul__
b = boo()
print b * 7
also explodes. Or am I misinterpreting the word "type" here?
Mick.
More information about the Python-list
mailing list