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

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:

主站蜘蛛池模板: 平潭县| 深州市| 安远县| 建昌县| 临夏县| 道孚县| 米易县| 阳信县| 姜堰市| 松江区| 弥渡县| 铅山县| 舒兰市| 安仁县| 青铜峡市| 遂溪县| 安吉县| 三河市| 双峰县| 高碑店市| 蒙阴县| 新晃| 海林市| 监利县| 洪江市| 米林县| 乌拉特后旗| 肥西县| 肇庆市| 南平市| 鄂托克前旗| 阜南县| 印江| 阳高县| 临桂县| 珲春市| 新安县| 靖江市| 延长县| 茌平县| 青龙|