5 ms·
> (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.
by settler4 8y 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.
- thomasahle 8y agoYou 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.