Regarding id() in python -
this question has answer here:
- “is” operator behaves unexpectedly integers 10 answers
i have doubt regarding id() in python.
>>> x=2 >>> y=2 >>> id(x) 94407182328128 >>> id(y) 94407182328128
but if same list,i different id's
>>> a=[1,2,3] >>> b=[1,2,3] >>> id(a) 139700617222048 >>> id(b) 139700617135528
why so? why int type id's same , why different lists?
thanks in advance.
python doesn’t have variables c. in c variable not name, set of bits; variable exists somewhere in memory. in python variables tags attached objects.
example:
regarding list part:
you created new reference .
more details illustrated in brilliant video:
Comments
Post a Comment