Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Show HN: Making Python one-liner-fit with the new pwk (Python With Kurly braces).
You can do this using contexlib. For example the following in pwk:
try: { print(os.listdir("/"+s.strip())) } except: pass
with contextlib.suppress(Exception): print(os.listdir("/"+s.strip()))
You could probably also make a context manager which takes a function/lambda to define how to handle exceptions etc.
You can do this using contexlib. For example the following in pwk:
Can be written in pure Python as: (Assuming contextlib is imported, and you're okay with letting things which don't extend Exception slip through.)You could probably also make a context manager which takes a function/lambda to define how to handle exceptions etc.