How can I define __getattr__ to operate on all items of container and pass arguments?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Tue Feb 15 21:58:25 CET 2011


On Tue, 15 Feb 2011 12:29:36 -0800, Jeremy wrote:

>     def __getattr__(self, name):
>         for I in self.items:
>             # How can I pass arguments to I.__dict__[name]?
>             I.__dict__[name]

The same way you would pass arguments to any other function: with 
function call syntax.

I.__dict__[name](arg1, arg2, arg3, ...)


-- 
Steven



More information about the Python-list mailing list