Python Notes Set 5
Python Notes Set 5
print(arg)
print(f"{key}: {value}")
LEGB Rule:
- Local
- Enclosing
- Global
- Built-in
contents = f.read()
@contextmanager
def managed_resource():
print("Setup")
yield
print("Cleanup")
Page 4: Multithreading
import threading
def worker():
print("Working")
t = threading.Thread(target=worker)
t.start()
t.join()
Good for I/O-bound tasks, not CPU-bound (use multiprocessing for that).
Page 5: Useful Built-in Functions