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

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:

主站蜘蛛池模板: 忻州市| 黄山市| 建阳市| 金华市| 额敏县| 鄂托克旗| 通州区| 澄江县| 雷波县| 通江县| 伊金霍洛旗| 和硕县| 泰州市| 吉水县| 苗栗县| 开远市| 东安县| 海林市| 乐山市| 遂平县| 迭部县| 准格尔旗| 黄平县| 五大连池市| 新平| 奉贤区| 长乐市| 旺苍县| 封开县| 正安县| 巴南区| 罗定市| 吴川市| 武冈市| 平山县| 财经| 武川县| 丰宁| 紫云| 延边| 潼关县|