The immutable object in python

后端 未结 4 400
旧时难觅i
旧时难觅i 2020-12-21 23:28

I see a article about the immutable object.

It says when:
variable = immutable
As assign the immutable to a variable.

for example

4条回答
  •  囚心锁ツ
    2020-12-22 00:07

    "Simple" immutable literals (and in particular, integers between -1 and 255) are interned, which means that even when bound to different names, they will still be the same object.

    >>> a = 'foo'
    >>> b = 'foo'
    >>> a is b
    True
    

提交回复
热议问题