proto-PEP: "unless" expression

Richard Jones rjones at ekit-inc.com
Sat Feb 8 01:52:21 EST 2003


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

Introduction

    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). 

Discussion

    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.

Examples

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






More information about the Python-list mailing list