[Python-Dev] Prototypes [was: Proper tail recursion]

A.M. Kuchling amk at amk.ca
Fri Jul 16 15:33:14 CEST 2004

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:

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.


More information about the Python-Dev mailing list