This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author r.david.murray
Recipients r.david.murray
Date 2012-11-12.00:17:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1352679459.02.0.414122398053.issue16457@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2012-11-12 00:17:39r.david.murraysetrecipients: + r.david.murray
2012-11-12 00:17:39r.david.murraysetmessageid: <1352679459.02.0.414122398053.issue16457@psf.upfronthosting.co.za>
2012-11-12 00:17:38r.david.murraylinkissue16457 messages
2012-11-12 00:17:38r.david.murraycreate