[Python-ideas] an unless statement would occasionally be useful

MRAB python at mrabarnett.plus.com
Sun May 17 23:07:02 CEST 2015


On 2015-05-17 21:31, Douglas La Rocca wrote:
> it could also be confused as a synonym for
>
>      while not condition:
>          ...
>
No, that would be:

     until condition:
         ...

which we don't want either. :-)

>> On May 17, 2015, at 4:28 PM, Mark Lawrence <breamoreboy at yahoo.co.uk> wrote:
>>
>>> On 17/05/2015 19:07, Charles Hixson wrote:
>>> I'm envisioning "unless" as a synonym for "if not(...):"  currently I use
>>>
>>> if .... :
>>>     pass
>>> else:
>>>   ...
>>>
>>> which works.
>>>
>>> N.B.:  This isn't extremely important as there are already two ways to
>>> accomplish the same purpose, but it would be useful, seems easy to
>>> implement, and is already used by many other languages.  The advantage
>>> is that when the condition is long it simplifies understanding.
>>
>> IMHO if a statement is only "occasionally useful" is should not be in the Python language.
>>



More information about the Python-ideas mailing list