On this page
oct
Prev: object | Up: __builtins__ | Next: open
Rel: ascii, bin, chr, format, hex
Ref: docs.python.org — oct
Tags: #public #python3 #builtins
Import & Availability
# Built-in (available globally without import)
from builtins import oct
Overview & Signature
oct(number, /)
Return the octal representation of an integer.
Usage
assert oct(0o755) == "0o755"
assert f"{0o755:o}" == "755"
Gotchas
- Includes
"0o"prefix: Commonly used when formatting Unix file permission bits (oct(st.st_mode & 0o777)).
REPL Inspect
help(oct)
Linked from
Related notes
- tuts/python3/__builtins__/__builtins__ Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/ascii 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__/object Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/open Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__ links to this page; shared tags: #builtins
- tuts/c/builtins shared tags: #builtins