PEP 315: Enhanced While Loop
During some random surfing I became interested in the below piece of code:
> while <condition1>:
> and while <condition2>:
> and while <condition3>:
> else: <other code>
It strikes me that the 'and while' syntax has some power that you may
not have considered. Consider that if an 'and while' were to be
executed under some condition:
and while <conditionY>:
you would then have a live loop condition that applied to subsequent
iterations only if conditionX was met. Under this circumstance I
wondered if you might also want a method of cancelling while
conditions? For example:
cancel while <conditionY>:
where the 'cancel while' command removes conditionY from the list of
conditions that the loop will terminate on. You could then also use
this syntax to cancel the initial while condition.
I also wondered if 'or while' might be better, so that you could add
different types of prefix to a while condition, i.e. 'and while'.
I'm a python novice so this could well be something you want to ignore
but I wasn't doing anything anyway. Let me know what you think.
|All times are GMT. The time now is 03:44 PM.|
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.