Enum HOWTO — Python 3.11.16 documentation

docs.python.org

Tin mới

Debugging C API extensions and CPython Internals with GDB

Functional Programming HOWTO

Python Module Index

3.11.16 Documentation

Programmatic access to enumeration members and their attributes¶

An Enum is a set of symbolic names bound to unique values. They are similar to global variables, but they offer a more useful repr(), grouping, type-safety, and a few other features.

Programmatic access to enumeration members and their attributes¶

An Enum is a set of symbolic names bound to unique values. They are similar to global variables, but they offer a more useful repr(), grouping, type-safety, and a few other features.

Programmatic access to enumeration members and their attributes¶

An Enum is a set of symbolic names bound to unique values. They are similar to global variables, but they offer a more useful repr(), grouping, type-safety, and a few other features.

Programmatic access to enumeration members and their attributes¶

An Enum is a set of symbolic names bound to unique values. They are similar to global variables, but they offer a more useful repr(), grouping, type-safety, and a few other features.

collections.namedtuple

The Enum class is callable, providing the following functional API:

Formatted string literals

Formatted string literals, str.format(), and format() will use the enum’s __str__() method.

Boolean value of Enum classes and members¶

Enum classes that are mixed with non-Enum types (such as int, str, etc.) are evaluated according to the mixed-in type’s rules; otherwise, all members evaluate as True. To make your own enum’s boolean evaluation depend on