(test?return_true:return_false)

Skip Montanaro skip at pobox.com
Thu Jan 23 11:30:18 EST 2003


Daniel asks about the moral equivalent of

        (matches==1?'':'es')

in Python.

The usual idiom for a simple case like this is

    matches > 1 and "es" or ""

You will discover more arcane variations on this theme over time.  They are
generally only useful in obfuscated Python contests, however.

Skip





More information about the Python-list mailing list