What you seem to be discussing is not normally known as a loop 
invariant.

"Loop invariants" are normally understood to be a form of invariant, 
i.e. something that doesn't change, not something which does change from 
iteration to iteration. A loop invariant is an assertion about the state 
of your program which is true at the beginning and end of each loop.

https://en.wikipedia.org/wiki/Loop_invariant

For example, we might make a trivial loop invariant like this:

    vowels = "aeiou"
    for c in vowels:
        # pointless loop invariant
        assert c in vowels

Invariants are normally assertions, which may be disabled without 
changing the meaning of the code.

I'm sorry, I don't see any benefit to your proposal aside from saving 
one line and one indent. I don't consider that sufficient benefit to 
make it worth adding redundant syntax to the language.



-- 
Steven
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/KDR6LGMXMKDYPGA7JIN5SCSK2SX2G6AG/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to