Comment

Comment by glifchits

Interesting! I figured the `as` in a `with` statement was handled uniquely, but I learned something new about Python today:

   x = open('filename')
   x.closed  # False
   with x:
     print(x.readline())
   x.closed  # True
I think you're right. I prefer the `as` variant for readability.
parent glifchits 8 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton