Python Glossary Русский

Python 3.11+enumfunction

enum.global_flag_repr

globalization

The repr function for members of a global_enum-decorated Flag.

Syntax

enum.global_flag_repr(member)

Flags need their own function because a combined value has no single name: the repr prints each flag with the module prefix joined by a pipe (re.ASCII|re.IGNORECASE) instead of one name as a plain enum would. When a value has no named flags behind it, the output falls back to the module.Class(number) form.

Examples

import enum
import re
print(callable(enum.global_flag_repr))   # → True
print(repr(re.IGNORECASE))   # → re.IGNORECASE
print(repr(re.IGNORECASE | re.MULTILINE))   # → re.IGNORECASE|re.MULTILINE
print(repr(re.RegexFlag.DOTALL))   # → re.DOTALL
print(re.RegexFlag.__repr__ is enum.global_flag_repr)   # → True

See also

Open in the full glossarydocs.python.orgReport an inaccuracy