proto-PEP: "unless" expression

Richard Jones rjones at
Sat Feb 8 07:52:21 CET 2003

Title: "unless" expression
Version: 1.0
Author: Richard Jones


    Many other languages offer multiple ways to perform a
    task. Users coming from these other languages often find
    Python's arbitrary constraints confusing. This PEP
    proposes an additional expression syntax that allows
    inverse logical matching in a similar framework to the
    if-then-else expression syntax (PEP 308). 


    This will allow the elimination of a logical inversion
    operation in some if-then expressions. Users coming from
    some other environments may find this expression form
    more comfortable too.

    This proposal introduces a new keyword, "unless", but
    nobody's going to be using it, so that's ok.


    >>> spam, beans = 'spam', 'beans'
    >>> print "spam, spam, spam" unless spam == beans
    spam, spam, spam

More information about the Python-list mailing list