[Python-3000] defop ?

Antoine solipsis at pitrou.net
Wed Nov 22 14:23:39 CET 2006


> 2. a 'defop' syntax as shorthand for 'addmethod()', such that e.g.:
>
>      import operator
>
>      class Foo:
>          defop iter(self):
>              ...
>          defop len(self):
>              ...
>          defop operator.getitem(self, key):
>              ...

Is "defop" useful?

Why wouldn't it be possible to enable special method lookup with this kind
of syntax:

iter = generic_function()
iter.lookup_special_method("__iter__")

And then the classical:

class Foo:
    def __iter__(self):
        pass





More information about the Python-3000 mailing list