On this page
sre_compile.dis
Prev: sre_compile.compile | Up: sre_compile | Next: sre_compile.error
Rel: sre_compile.compile, sre_compile.error, sre_compile.isstring, sre_compile.PatternError
Ref: docs.python.org — sre_compile.dis
Tags: #public #python3 #stdlib #sre_compile
Import
import sre_compile
from sre_compile import dis
Signature & Overview
sre_compile.dis(code)
sre_compile.dis() function.
Usage
import contextlib, io, re
# Use re.compile(pattern, re.DEBUG) to inspect compiled regex opcodes
buf = io.StringIO()
with contextlib.redirect_stdout(buf):
re.compile(r'a+', re.DEBUG)
assert 'MAX_REPEAT' in buf.getvalue()
Gotchas
- Deprecated internal shim.
REPL Inspect
from sre_compile import dis
help(dis)
Linked from
Related notes
- tuts/python3/stdlib_module/sre_compile Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/sre_compile/compile Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/sre_compile/error Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/sre_compile/isstring Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/sre_compile/PatternError Linked here; links to this page; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib
- tuts/c/stdlib/assert/static_assert shared tags: #stdlib
- tuts/c/stdlib/ctype shared tags: #stdlib