官术网_书友最值得收藏!

Immutable sets

Python has an immutable set type called frozenset. It works pretty much exactly like set apart from not allowing methods or operations that change values such as the add() or clear() methods. There are several ways that this immutability can be useful. For example, since normal sets are mutable and therefore not hashable, they cannot be used as members of other sets. The frozenset, on the other hand, is immutable and therefore able to be used as a member of a set:

Also the immutable property of frozenset means we can use it for a key to a dictionary, for example:

主站蜘蛛池模板: 锦屏县| 静宁县| 阿合奇县| 泰安市| 遂川县| 桑植县| 文昌市| 邵东县| 铜陵市| 彰化市| 东乌| 乐业县| 南昌县| 镇康县| 北流市| 故城县| 汾西县| 江川县| 寿宁县| 古交市| 永德县| 芮城县| 京山县| 永胜县| 五家渠市| 万源市| 高州市| 青龙| 永济市| 乌拉特后旗| 南木林县| 双桥区| 密云县| 济南市| 新蔡县| 玉林市| 忻城县| 永善县| 南召县| 焦作市| 庄河市|