On this page
enum.global_str
Prev: enum.global_flag_repr | Up: enum | Next: enum.IntEnum
Rel: enum.auto, enum.Enum, enum.EnumCheck, enum.EnumDict
Ref: docs.python.org — enum.global_str
Tags: #public #python3 #stdlib #enum
Import
import enum
from enum import global_str
Signature & Overview
enum.global_str(self)
use enum_name instead of class.enum_name
Usage
from enum import Enum, global_str
class Code(Enum):
OK = 0
assert global_str(Code.OK) == "OK"
Gotchas
- Python 3.11+: Returns the bare member name without the class prefix; applied automatically by
@global_enum.
REPL Inspect
from enum import global_str
help(global_str)
Linked from
Related notes
- tuts/python3/stdlib_module/enum/global_flag_repr Linked here; links to this page; shared tags: #enum, #stdlib
- tuts/python3/stdlib_module/enum/IntEnum Linked here; links to this page; shared tags: #enum, #stdlib
- tuts/python3/stdlib_module/enum/auto Linked here; shared tags: #enum, #stdlib
- tuts/python3/stdlib_module/enum/Enum Linked here; shared tags: #enum, #stdlib
- tuts/python3/stdlib_module/enum/EnumCheck Linked here; shared tags: #enum, #stdlib
- tuts/python3/stdlib_module/enum/EnumDict Linked here; shared tags: #enum, #stdlib
- tuts/python3/stdlib_module/enum links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/enum/EnumMeta shared tags: #enum, #stdlib
- tuts/python3/stdlib_module/enum/EnumType shared tags: #enum, #stdlib
- tuts/python3/stdlib_module/enum/Flag shared tags: #enum, #stdlib