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

Cory Benfield cory at lukasa.co.uk
Sun May 17 21:02:34 CEST 2015


> On 17 May 2015, at 19:07, Charles Hixson <charleshixsn at earthlink.net> wrote:
> 
> I'm envisioning "unless" as a synonym for "if not(...):"  currently I use
> 
> if .... :
>    pass
> else:
>
That’s interesting, Personally, I think I’d invert that conditional (or, if the rest of the body is long, do an early return).

Playing the role of opposition for a moment, I’d argue that we don’t need ‘unless’ because we already have a spelling for that: ‘if not’. Is it not said: "There should be one-- and preferably only one --obvious way to do it.”?


More information about the Python-ideas mailing list