[Python-Dev] Prototypes [was: Proper tail recursion] (original) (raw)

Barry Warsaw barry at python.org
Fri Jul 16 16:14:42 CEST 2004


On Fri, 2004-07-16 at 09:33, A.M. Kuchling wrote:

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

I've wanted this for a long time, but I don't think Guido's ever been in favor of this.

Could function decorators be used for this? Something like:

Possibly so, and that's kind of neat.

@attachtoobject(Account) def deposit (self, v): ... del deposit

The decorator couldn't delete the binding of 'deposit' in the current namespace, however.

Couldn't you play sys._getframe() tricks inside the decorator to do this?

-Barry

-------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 307 bytes Desc: This is a digitally signed message part Url : http://mail.python.org/pipermail/python-dev/attachments/20040716/da2d4985/attachment.pgp



More information about the Python-Dev mailing list