chained attrgetter

Brian Beck exogen at gmail.com
Thu Oct 26 05:02:35 EDT 2006


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(), using operator.attrgetter just makes the
definition more complicated (see my other post).

--
Brian Beck
Adventurer of the First Order




More information about the Python-list mailing list