Python tty Module
Example
Set terminal to cbreak mode (Unix only):
import tty
import sys
try:
tty.setcbreak(sys.stdin.fileno())
print('Terminal set to cbreak mode')
except (OSError, AttributeError):
print('Could not set cbreak mode (not a terminal)')
Try it Yourself »
Definition and Usage
The tty module provides terminal control functions for Unix systems.
Use it to set terminal modes like raw mode or cbreak mode for character-by-character input.
Note: This module is only available on Unix systems.
Members
Member | Description |
---|---|
setcbreak() | Set cbreak mode (minimal line buffering). |
setraw() | Set raw mode (no line buffering or special character handling). |