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.) _______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
