[ SRE_ARENA ]
Roadmap
System Design
SREdle
⚡ 1420 ELO
OP
☰
←
BACK TO ROADMAP
FILE HANDLING
File Handling & Config Parsing
System Architecture Visualization
config.json
Disk
open()
with open(...)
json.load()
Parse String
Dictionary
Memory
Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.
Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.
Reading & Writing Files
Parsing JSON
Parsing YAML
DOWNLOADING CONCEPT: READING & WRITING FILES...
↳
The
open()
function returns a file object.
↳
ALWAYS use the
with
context manager, which ensures the file is safely closed even if an exception occurs.
python
with open('/var/log/syslog', 'r') as f: for line in f: print(line.strip())
▲ LIVE INCIDENT
A script reading a massive 10GB log file crashes the server.
sre@arena:~/python-file-io
sre@arena
:
~
$
python3 parse_logs.py
▶ EXECUTE COMMAND