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

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:

主站蜘蛛池模板: 京山县| 佛学| 玛曲县| 固原市| 栾川县| 阜新市| 永昌县| 长沙市| 桐城市| 黑水县| 荃湾区| 铅山县| 丰原市| 三都| 来宾市| 秦皇岛市| 泸西县| 房产| 侯马市| 乌拉特中旗| 青川县| 济阳县| 土默特左旗| 安徽省| 昂仁县| 浪卡子县| 濮阳县| 卢湾区| 盐城市| 正定县| 兰溪市| 孟连| 汉中市| 南川市| 长葛市| 西乡县| 平阳县| 梁河县| 如东县| 大英县| 贵德县|