Stackoverflow question: Is there a built-in identity function in Python?

Ethan Furman ethan at stoneleaf.us
Thu Dec 7 16:03:22 EST 2017


On 12/07/2017 12:24 PM, Peter Otten wrote:

> identity((a, b, c))
>
> calls identity() with one argument whereas
>
> identity(a, b, c)
>
> calls identity() with three arguments. That's certainly an effect; you just
> undo it with your test for len(args) == 1. That means that your identity()
> function throws away the information about the number of arguments it was
> called with. I would expect an identity() function to be lossless
> ("bijective") and I think that is possible only if you restrict it to a
> single argument.

Thanks for exposing/clarifying that flaw.  I have removed my answer.

--
~Ethan~




More information about the Python-list mailing list