Stackoverflow question: Is there a built-in identity function in Python?
Peter Otten
__peter__ at web.de
Thu Dec 7 13:53:43 EST 2017
Ethan Furman wrote:
> The simple answer is No, and all the answers agree on that point.
>
> It does beg the question of what an identity function is, though.
>
> My contention is that an identity function is a do-nothing function that
> simply returns what it was given:
>
> --> identity(1)
> 1
>
> --> identity('spam')
> 'spam'
>
> --> identity('spam', 'eggs', 7)
> ('spam', 'eggs', 7)
Hm, what does -- and what should --
identity(('spam', 'eggs', 7))
produce?
>
> Of the five answers to that SO question, mine is the only one that will
> correctly handle those three examples. If you
> agree with my contention feel free to up-vote my answer. :)
>
> https://stackoverflow.com/a/8748063/208880
>
> --
> ~Ethan~
More information about the Python-list
mailing list