Re: chained attrgetter

2006-10-26 Thread David S.
Ah, pretty Python. Thanks, all. -- http://mail.python.org/mailman/listinfo/python-list

Re: chained attrgetter

2006-10-26 Thread Brian Beck
David S. wrote: > Does something like operator.getattr exist to perform a chained attr > lookup? > > I came up with the following, but I can not help but think it is > already done and done better. You were on the right track, but the built-in getattr is a perfectly good argument to reduce(), usin

Re: chained attrgetter

2006-10-26 Thread Brian Beck
Alexey Borzenkov wrote: > Do you mean something like > > class cattrgetter: > def __init__(self, name): > self.names = name.split('.') > def __call__(self, obj): > for name in self.names: > obj = getattr(obj, name) > return obj I'll raise you one: def c

Re: chained attrgetter

2006-10-25 Thread Alexey Borzenkov
On Oct 25, 10:00 pm, "David S." <[EMAIL PROTECTED]> wrote: > Does something like operator.getattr exist to perform a chained attr > lookup? Do you mean something like class cattrgetter: def __init__(self, name): self.names = name.split('.') def __call__(self, obj): for nam

chained attrgetter

2006-10-25 Thread David S.
Does something like operator.getattr exist to perform a chained attr lookup? I came up with the following, but I can not help but think it is already done and done better. Peace, David S. def compose(funcs): """ return composite of funcs this does not support extended call syntax, so