Hacker News new | ask | show | jobs
by settler4 2896 days ago
> (a := b)

Will `with` start using this syntax instead of `b as a`: `with open('foo') as a:` == `with a := open('foo'):`?

Update: found my answer on the pep. `with EXPR as VAR` actually calls `EXPR.__enter__()` so it's not the same.

1 comments

You mean `with EXPR as VAR` lets `VAR = EXPR.__enter__()`. Because `with EXPR` also calls `EXPR.__enter__()`, so `with VAR := EXPR` would too.

Seems very unnecessary to have both options.