__getattribute__ and methods proxying

Stephen Hansen me+list/python at ixokai.io
Sat Jun 12 17:05:17 EDT 2010


On 6/12/10 12:59 PM, Giampaolo Rodolà wrote:
> Clear, thanks.
> Isn't there a prettier/common way to do this?
> A __methodcall__(self, method_obj) special method or something? Has
> something like that ever been proposed for inclusion?

Not really, because that doesn't actually fit into the object model. A
class isn't actually involved with the calling of the method: once the
class returns it, the method's own __call__ is invoked later on. The
class is completely out of touch at that point.

The idiomatic way is really returning a wrapped function-- or using
decorators (which is just more explicit wrapping), I think.

-- 

   Stephen Hansen
   ... Also: Ixokai
   ... Mail: me+list/python (AT) ixokai (DOT) io
   ... Blog: http://meh.ixokai.io/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 487 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20100612/28d148c4/attachment.sig>


More information about the Python-list mailing list