Josiah Carlson wrote:
>
> Ahh, so you want to pass the method name to the method that you are 
> returning to be called.  No problem.
> 
>  >>> import functools
>  >>>
>  >>> class foo:
> ...     def __getattr__(self, name):
> ...         return functools.partial(self.ActualMethod, name)
> ...
> ...     def ActualMethod(self, name, *args, **kwargs):
> ...         #handle *args and **kwargs based on name!
> ...         print name, args, kwargs
> ...
>  >>> foo().bar('hello', world=1)
> bar ('hello',) {'world': 1}
>  >>>

Thanks, this is exactly what I was looking for! For some reason functools 
didn't even show up at all during Google searches...must have just had the 
wrong search terms.

-Jay

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to