Loading topic
== and is. You need Python 3.8 or later. Later chapters mention a few features that need newer versions, and they say so where i2 min readEnum class and that you know how classes, attributes and exceptions work. It covers how to read a member's name and value, and how to find a member from either one.2 min readEnum class and read .name and .value, as covered earlier. You should also know how == differs from is. Here you will loop over an enum, see what iteration leaves out, and learn how alias names work.2 min readEnum, how iteration skips aliases, and how decorators wrap a class. If aliases are new to you, review the previous chapter first.2 min readEnum class and read a member's .name and .value. It also assumes you know what @unique does. Often the specific values don't matter and you only need each member to be distinct. In that case auto() lets Python pick them.2 min read== and is, and that you can define a basic Enum class. It covers how members compare, why plain enums refuse ordering, and what hashing means for dictionaries and sets.2 min read@property, and how to define Enum classes with .name and .value. Enum members are real objects, so they can carry behavior and extra data.2 min readEnum, read .name and .value, and know that members are singletons compared with is or ==. Here you will use enums as types, as dictionary keys, and as match patterns.2 min readEnum, read .name and .value, and tell == from is. It builds on those ideas to show enums whose members also act as ordinary integers or strings.3 min readEnum, how auto() assigns values, and how Python's bitwise operators (|, &, ~) work on integers. The examples use Python 3.11 or later.3 min readEnum, read .name and .value, and tell == from is. It also assumes you know what IntEnum and StrEnum are. The mistakes below are the ones that most often surprise people after the basics.2 min readEnum, read .name and .value, and look members up with Color(2) and Color["BLUE"]. It also assumes you know what auto() does.2 min readEnum, look members up with Color(2) and Color["BLUE"], and use auto(). It also assumes you know what a classmethod is. Two small hooks let you change how an enum finds members and how auto() picks values.2 min read