What is a function parameter =[] for?

Dave Farrance df at see.replyto.invalid
Thu Nov 26 05:34:43 EST 2015


Alan Bawden <alan at csail.mit.edu> wrote:

>Chris Angelico <rosuav at gmail.com> writes:
> ...
>> Python 2.7.8 (2.4.0+dfsg-3, Dec 20 2014, 13:30:46)
>> [PyPy 2.4.0 with GCC 4.9.2] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
>>>>>> tuple([]) is tuple([])
>> False
>
>I said I wouldn't be suprised if it was always true, but that doesn't
>imply that I need to be suprised if it is sometimes false!
>
>Having said that, I _am_ curious whether that remains False for various
>other variant expressions.  "tuple([])" is actually a rather perverse
>way to obtain an empty tuple.  How about plain "() is ()"? ...

Still false in PyPy it seems

[PyPy 2.6.1 with GCC 4.9.2] on linux2
>>>> id(())
139836165383760L
>>>> id(())
139836165383776L

(Conversely, I see that unlike CPython, all PyPy's numbers have
unchanging ids, even after exiting PyPy and restarting, so it seems that
PyPy's numerical ids are "faked".)

[PyPy 2.6.1 with GCC 4.9.2] on linux2
>>>> id(1+2j)
679900119843984469027190799480815353863L

[PyPy 2.6.1 with GCC 4.9.2] on linux2
>>>> id(1+2j)
679900119843984469027190799480815353863L



More information about the Python-list mailing list