[Python-3000] defop ?

Phillip J. Eby pje at telecommunity.com
Thu Nov 23 05:34:25 CET 2006


At 10:59 PM 11/22/2006 -0500, Calvin Spealman wrote:
>Perhaps we could allow a special type of key in __dict__'s (and
>__slots__'s ?) that was more than a simple string name but included a
>namespace or context in which the name was to be understood. Even a
>simple 2-tuple would be enough. (operator, 'len') might be the entry
>for a method that the len builtin called, for example. A simple syntax
>would preceed the . operator to create names with this convention,
>maybe even using the familiar :: from other languages.
>
>class myclass(object):
>     def operator::len(self):
>         return self.length
>     ...
>
>Very simple, can have more uses than the single, limited use case
>being discussed.

So, how does that work for adding methods after the fact, *outside* of a 
class?  (See Guido's BinaryTree flattening example.)



More information about the Python-3000 mailing list