eeOn Thu, Jul 15, 2004 at 09:22:25PM -0400, Raymond Hettinger wrote: > helping out people who want to experiment with prototype OO. The > request is make it possible to write: > > def Account.deposit(self, v): > self.balance += v Could function decorators be used for this? Something like: @attach_to_object(Account) def deposit (self, v): ... del deposit The decorator couldn't delete the binding of 'deposit' in the current namespace, however. Decorators could return a magic value that meant "don't create a binding for the function", but that seems only useful for this one use case. Or maybe the decorator would record the name internally, and after defining all the methods you'd call a cleanup function that deleted them from the module namespace. --amk
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4