On 1/1/2021 2:00 PM, Jonathan Fine wrote:

By the way, this surprised me. Would anyone like to explain this?
    >>> id(f()), id(f())
    (139927013695536, 139927013695536)

id's are only unique while an object exists. Here the object returned by the first call is discarded after its id is taken. Then the second object is created and reuses the memory address that was used by the first object. Since in CPython id() returns object's memory address, the id's are the same.

Eric