On Fri, 3 Sept 2021 at 12:06, Steven D'Aprano <[email protected]> wrote:
>
> I think it might be better to start with a *function* that chains
> subscript calls, and perhaps put it in the operator module with
> itemgetter and attrgetter.
>
>     # Untested.
>     def chained_item(items, obj):
>         for key in items:
>             obj = obj[key]
>         return obj

That's an interesting idea, but why chain only subscript calls?
chained_item chains application of the callable objects from the
iterable

  map(operator.itemgetter, items)

It would be sufficient and more convenient if functools had something
that chains application of any callable objects.

Best regards,
Takuo
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/XOLZXM53MUJW4JSZ47J2IU27SNMRFKBG/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to