frobozz_electric at hotmail.com
Sat Jan 25 00:14:53 CET 2003
"Robin Munn" <rmunn at pobox.com> wrote in message
news:slrnb32738.5jj.rmunn at localhost.localdomain...
> So for the example you quoted:
> print 'Search complete (%d match%s
> the "a and b or c" trick won't work, since an empty string is considered
> false. You would need to invert the test. Instead of:
> (matches==1) and '' or 'es'
> (matches!=1) and 'es' or ''
> This will work properly.
Or, from the "Python Cookbook":
(matches == 1 and [''] or ['es'])
('', 'es')[matches != 1]
or, for plurals in particular,
's'*(matches != 1)
More information about the Python-list