On this page
enum.FlagBoundary
Prev: enum.Flag | Up: enum | Next: enum.global_enum
Rel: enum.auto, enum.Enum, enum.EnumCheck, enum.EnumDict
Ref: docs.python.org — enum.FlagBoundary
Tags: #public #python3 #stdlib #enum
Import
import enum
from enum import FlagBoundary
Signature & Overview
enum.FlagBoundary(*values)
control how out of range values are handled "strict" -> error is raised [default for Flag] "conform" -> extra bits are discarded
Methods & Attributes
FlagBoundary.capitalize(self, /)— Return a capitalized version of the string.FlagBoundary.casefold(self, /)— Return a version of the string suitable for caseless comparisons.FlagBoundary.center(self, width, fillchar=' ', /)— Return a centered string of length width.FlagBoundary.count(...)— Return the number of non-overlapping occurrences of substring sub in string S[start:end].FlagBoundary.encode(self, /, encoding='utf-8', errors='strict')— Encode the string using the codec registered for encoding.FlagBoundary.endswith(...)— Return True if the string ends with the specified suffix, False otherwise.FlagBoundary.expandtabs(self, /, tabsize=8)— Return a copy where all tab characters are expanded using spaces.FlagBoundary.find(...)— Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end].FlagBoundary.format(self, /, *args, **kwargs)— Return a formatted version of the string, using substitutions from args and kwargs.FlagBoundary.format_map(self, mapping, /)— Return a formatted version of the string, using substitutions from mapping.FlagBoundary.index(...)— Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end].FlagBoundary.isalnum(self, /)— Return True if the string is an alpha-numeric string, False otherwise.FlagBoundary.isalpha(self, /)— Return True if the string is an alphabetic string, False otherwise.FlagBoundary.isascii(self, /)— Return True if all characters in the string are ASCII, False otherwise.FlagBoundary.isdecimal(self, /)— Return True if the string is a decimal string, False otherwise.FlagBoundary.isdigit(self, /)— Return True if the string is a digit string, False otherwise.FlagBoundary.isidentifier(self, /)— Return True if the string is a valid Python identifier, False otherwise.FlagBoundary.islower(self, /)— Return True if the string is a lowercase string, False otherwise.FlagBoundary.isnumeric(self, /)— Return True if the string is a numeric string, False otherwise.FlagBoundary.isprintable(self, /)— Return True if all characters in the string are printable, False otherwise.FlagBoundary.isspace(self, /)— Return True if the string is a whitespace string, False otherwise.FlagBoundary.istitle(self, /)— Return True if the string is a title-cased string, False otherwise.FlagBoundary.isupper(self, /)— Return True if the string is an uppercase string, False otherwise.FlagBoundary.join(self, iterable, /)— Concatenate any number of strings.FlagBoundary.ljust(self, width, fillchar=' ', /)— Return a left-justified string of length width.FlagBoundary.lower(self, /)— Return a copy of the string converted to lowercase.FlagBoundary.lstrip(self, chars=None, /)— Return a copy of the string with leading whitespace removed.FlagBoundary.maketrans(...)— Return a translation table usable for str.translate().FlagBoundary.partition(self, sep, /)— Partition the string into three parts using the given separator.FlagBoundary.removeprefix(self, prefix, /)— Return a str with the given prefix string removed if present.FlagBoundary.removesuffix(self, suffix, /)— Return a str with the given suffix string removed if present.FlagBoundary.replace(self, old, new, /, count=-1)— Return a copy with all occurrences of substring old replaced by new.FlagBoundary.rfind(...)— Return the highest index in S where substring sub is found, such that sub is contained within S[start:end].FlagBoundary.rindex(...)— Return the highest index in S where substring sub is found, such that sub is contained within S[start:end].FlagBoundary.rjust(self, width, fillchar=' ', /)— Return a right-justified string of length width.FlagBoundary.rpartition(self, sep, /)— Partition the string into three parts using the given separator.FlagBoundary.rsplit(self, /, sep=None, maxsplit=-1)— Return a list of the substrings in the string, using sep as the separator string.FlagBoundary.rstrip(self, chars=None, /)— Return a copy of the string with trailing whitespace removed.FlagBoundary.split(self, /, sep=None, maxsplit=-1)— Return a list of the substrings in the string, using sep as the separator string.FlagBoundary.splitlines(self, /, keepends=False)— Return a list of the lines in the string, breaking at line boundaries.
Usage
from enum import CONFORM, STRICT, Flag, FlagBoundary
class Mode(Flag, boundary=FlagBoundary.STRICT):
A = 1
B = 2
assert Mode(3) == (Mode.A | Mode.B)
Gotchas
- Controls out-of-range bits (Python 3.11+):
STRICTraisesValueError,CONFORMdrops unknown bits,EJECTreturns a plainint, andKEEPpreserves unknown bits.
REPL Inspect
from enum import FlagBoundary
help(FlagBoundary)
Linked from
Related notes
- tuts/python3/stdlib_module/enum/Flag Linked here; links to this page; shared tags: #enum, #stdlib
- tuts/python3/stdlib_module/enum/global_enum 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/global_enum_repr shared tags: #enum, #stdlib