[OT] Number theory [Was: A use for integer quotients]
Martin Sjögren
martin at strakt.com
Mon Jul 30 02:50:59 EDT 2001
On Mon, Jul 30, 2001 at 05:55:59AM +0000, Marcin 'Qrczak' Kowalczyk wrote:
> Sun, 29 Jul 2001 22:20:09 GMT, Bengt Richter <bokr at accessone.com> pisze:
>
> > BTW, note the usefulness of boolean-as-integer returned from
> > comparison operators, if you want to be picky about plurals:
> >
> > print "There %s %d error%s." % ( ['were','was'][n==1], n, 's'*(n!=1) )
>
> I would write it
> print "There %s %d error%s." % (if n==1 then ('was', n, '')
> else ('were', n, 's'))
> if I could.
I would write it
if n == 1:
print "There was one error."
else:
print "There were %d errors." % n
If you've ever tried to translate programs to other languages, using
gettext for example, you quickly realize that all other constructs are
abominations and impossible to translate to other languages.
Okay, that was off topic :)
Martin
--
Martin Sjögren
martin at strakt.com ICQ : 41245059
Phone: +46 (0)31 405242 Cell: +46 (0)739 169191
GPG key: http://www.strakt.com/~martin/gpg.html
More information about the Python-list
mailing list