with — Expert Playground
Wraps a block with a context manager for automatic setup/teardown
Python Playground
Output
Click "Run" to execute your codeasync with uses __aenter__ and __aexit__ for async setup/teardown. The bytecode uses BEFORE_ASYNC_WITH instead of BEFORE_WITH.
Challenge
Try modifying the code above to explore different behaviors. Can you extend the example to handle a new use case?