Message175412
Consider this code snippet, simplified from a real application:
def display(self, *columns)
getter = attrgetter(*columns)
toprint = [[str(x) for x in getter(row)] for row in self._rows]
This works great...as long as there are two or more columns to print.
If there is only one column, it bombs because the getter returns a value
instead of a tuple.
This would not be a problem in and of itself, but there is no way to
tell attrgetter that I want a tuple even if there is only one value.
I believe it would be backward compatible to allow:
attrgetter(['a'])
itemgetter(['a', 'b'])
to return a tuple, since a list cannot be an attribute name. The same
would apply to itemgetter, since a list cannot be a dictionary key. |
|
Date |
User |
Action |
Args |
2012-11-12 00:17:39 | r.david.murray | set | recipients:
+ r.david.murray |
2012-11-12 00:17:39 | r.david.murray | set | messageid: <1352679459.02.0.414122398053.issue16457@psf.upfronthosting.co.za> |
2012-11-12 00:17:38 | r.david.murray | link | issue16457 messages |
2012-11-12 00:17:38 | r.david.murray | create | |
|