what happens when i print in python, how does it show up in terminal
tags: learning terminal programming
content
- when i do
printin python, the python program doesn’t actually print to terminal - the program sends bytes to stdout, and stdout happens to be a terminal
- and then the terminal decides how to deal with it
- terminal deals with the incoming bytes based on some protocol, and deals with escape sequence accordingly
- e.g., if it’s
^[[A, terminal moves cursor up by 1 row^[is the start of control sequence
- e.g., if it’s
- terminal deals with the incoming bytes based on some protocol, and deals with escape sequence accordingly
print("hi")
↓
Python runtime
↓
UTF-8 bytes
↓
OS write() syscall
↓
stdout file descriptor
↓
terminal emulator
↓
escape-sequence parser
↓
screen update