On this page
ascii
Prev: any | Up: __builtins__ | Next: bin
Rel: bin, chr, format, hex, oct
Ref: docs.python.org — ascii
Tags: #public #python3 #builtins
Import & Availability
# Built-in (available globally without import)
from builtins import ascii
Overview & Signature
ascii(obj, /)
Return an ASCII-only representation of an object.
Usage
assert ascii("café 🐍") == "'caf\\xe9 \\U0001f40d'"
Gotchas
- Like
repr(), escaping all non-ASCII characters: Useful when writing pure-ASCII logs or diagnostics.
REPL Inspect
help(ascii)
Linked from
Related notes
- tuts/python3/__builtins__/__builtins__ Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/any Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/bin Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/chr Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/format Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/hex Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/oct Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__ links to this page; shared tags: #builtins
- tuts/python3/__builtins__/ord links to this page; shared tags: #builtins
- tuts/c/builtins shared tags: #builtins