Stackoverflow question: Is there a built-in identity function in Python?
Ethan Furman
ethan at stoneleaf.us
Thu Dec 7 14:41:13 EST 2017
On 12/07/2017 11:23 AM, Ned Batchelder wrote:
> On 12/7/17 1:28 PM, Ethan Furman wrote:
>> --> identity('spam', 'eggs', 7)
>> ('spam', 'eggs', 7)
>
> I don't see why this last case should hold. Why does the function take more than one argument? And if it does, then
> why doesn't it work like this?
>
> --> identity('spam')
> ('spam',)
>
> (because then it wouldn't be an identity function!) Trying to handle the multi-argument case seems like it adds an
> unneeded special case to the function.
--> a = 'spam'
--> a == neds_identity(a)
False
;)
--
~Ethan~
More information about the Python-list
mailing list