frozenset can be altered by |=
Jach Feng
jfong at ms4.hinet.net
Sun Nov 21 03:30:18 EST 2021
Marco Sulla 在 2021年11月20日 星期六上午5:12:19 [UTC+8] 的信中寫道:
> (venv_3_10) marco at buzz:~$ python
> Python 3.10.0 (heads/3.10-dirty:f6e8b80d20, Nov 18 2021, 19:16:18)
> [GCC 10.1.1 20200718] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> a = frozenset((3, 4))
> >>> a
> frozenset({3, 4})
> >>> a |= {5,}
> >>> a
> frozenset({3, 4, 5})
There is no CONSTANT in Pyhton as other languages does. The only way to have it is using special naming convention, such as in all capital letters, to remind yourself not to re-assign it:-)
--Jach
More information about the Python-list
mailing list