[issue16457] Allow operator 'getter' methods to take a list and return a tuple

Raymond Hettinger report at bugs.python.org
Tue Nov 13 05:17:54 CET 2012


Raymond Hettinger added the comment:

It's unfortunate that the automatic scalar/tuple switchover design doesn't play well with start-args.  We have the same issue arising in a number of places (for example, min(*args) isn't happy when args is of length 1).

While inconvenient for variable length argument lists, I don't think the proposed solution is clean.  As it currently stands, the signature is reasonably simple, easy to explain, and doesn't depend on exact type checks (like %-formatting does with tuple/dict arguments).

Instead of contorting the signature for itemgetter(), it would be better if the use case were to be addressed with the existing language features:

>>> t = tuple('abcdefghi')
>>> for columns in ([], [2], [2,4], [2,4,6]):
	print(tuple(t[i] for i in columns))
	
()
('c',)
('c', 'e')
('c', 'e', 'g')

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16457>
_______________________________________


More information about the Python-bugs-list mailing list