[Python-ideas] Optional kwarg making attrgetter & itemgetter always return a tuple

alex23 wuwei23 at gmail.com
Fri Sep 14 11:41:43 CEST 2012

On Sep 13, 11:15 pm, Masklinn <maskl... at masklinn.net> wrote:
>     # works the same no matter what len(indices) is
>     slicer = operator.itemgetter(*indices, force_tuple=True)

I'd be inclined to write that as:

    slicer = force_tuple(operator.itemgetter(*indices))

With force_tuple then just being another decorator.

More information about the Python-ideas mailing list