On Wed, 2 Mar 2022 at 18:35, Rob Cliffe via Python-ideas <python-ideas@python.org> wrote:
This doesn't obscure the control flow any more than a 'while' loop, It certainly does! I see a decorated function. Nothing tells me that
On 02/03/2022 02:01, Chris Angelico wrote: the decorator actually *calls* the function. This really is obscurantism.
"while True:" doesn't say that the loop will be executed at most once. How is this any worse? Given that you get to choose the name of the function AND the name of the decorator, I hardly think that you're really losing out here/
(b) AFAICS If you want to alter variables local to the outer function, you have to declare them non-local in the inner function. Yes, that's true. But that's not very common. That's your opinion. It happens in my code.
Can you post an example where you need a large number of nonlocals? A single nonlocal is hardly a major problem.
This is also true, but for the use-case you're describing, where you want to break at arbitrary points, it seems highly likely that you'd want to initialize it to some default. So in theory, this is a problem, but in practice, almost never. AFAIK it doesn't happen in my code, but I can easily imagine that it might.
Like I said, in theory a problem, in practice, not. I have *never once* run into this; in fact, I had to quickly check a couple of options to confirm that they indeed didn't work, because I've never been in a position of needing that.
for _ in '1': # Execute this 'loop' once only (break once we know how to ...) <code containing `break`s>
You've not convinced me that there is anything better than the above (for my needs). No new idioms, no opaque decorators, no obscuring the control flow, no need to worry about variable scopes. I would like a better way to spell it, but that's a minor cosmetic issue.
Very minor. You have quite a number of alternatives to choose from, and not one of them needs new syntax. ChrisA