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

Lele Gaifax lele at metapensiero.it
Thu Dec 7 14:29:03 EST 2017


Chris Angelico <rosuav at gmail.com> writes:

> On Fri, Dec 8, 2017 at 5:53 AM, Peter Otten <__peter__ at web.de> wrote:
>>
>> Hm, what does -- and what should --
>>
>> identity(('spam', 'eggs', 7))
>>
>> produce?
>
> The same thing. And so should identity((('spam', 'eggs', 7))) and
> identity(((('spam', 'eggs', 7)))) and identity((((('spam', 'eggs',
> 7))))).
>
> For consistency, identity 'spam', 'eggs', 7 should work too.

So you think that

  identity('spam', 'eggs', 7) \
    == identity(('spam', 'eggs', 7)) \
    == identity((('spam', 'eggs', 7),)) \
    == identity(((('spam', 'eggs', 7),),))

should yield True?

ciao, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
lele at metapensiero.it  |                 -- Fortunato Depero, 1929.




More information about the Python-list mailing list