El dom, 7 feb 2021 a las 3:08, MRAB (<pyt...@mrabarnett.plus.com>) escribió:
> On 2021-02-07 00:57, Jonathan Crall wrote: > > > [snip] > > > > To be clear, in the proposed syntax: > > > > if [condition] with [obj]: > > [code] > > > > Would behave exactly as: > > > > if [condition]: > > with [obj]: > > [code] > > > > Is there any chance that this conditional context manager syntax might be > > considered? Does anyone but myself think this might be a good idea? > > > -1. It's not that much shorter. You wouldn't be saving much typing or > space. > TL;DR: -1 for other reasons Space saved is similar to (really not necesary, but very convenient) `elif`: 4 spaces by line. My doubts are not by space saved, instead are for convenience. Nested ifs are very common contruction and there are not much to thing about. I doubt than `with` after `if` and with same scope that `if` isn't a very improbable structure. Other thing strange about proposal is: why only with after if? What about `else` (in `if`, `for`, `while`), `elif`, `for`, `while`? And in `try`, `except`, `else`, `finally`? When is coherent an mixed `with` and when not? As programmer I wan't think too much about language, so I need consistence to get focused in resolve problems with it. If I see uncommon `with` after `if` with same scope to be convenient, the other constructions needed to coherence and consistence in language seems very very strange to need (or even think in) syntactic sugar. regards, Javi
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/HLUEFZ45UN7WLGAARGWYCN7CITBGM2FX/ Code of Conduct: http://python.org/psf/codeofconduct/