[OT] Number theory [Was: A use for integer quotients]
bokr at accessone.com
Mon Jul 30 17:49:53 EDT 2001
On Mon, 30 Jul 2001 11:43:48 +0300, Moshe Zadka <m at moshez.org> wrote:
>On 30 Jul 2001, Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl> wrote:
>> I would write it
>> print "There %s %d error%s." % (if n==1 then ('was', n, '')
>> else ('were', n, 's'))
>The correct way to write it is:
>print ["There was %d error", "There were %d errors"][n>1] % n
I like that, but in English "There was 0 error" doesn't sound right to me,
so I would change your '>' to '!='. Maybe we need 3 alternatives?
>This way, making this application translatable is a piece of cake.
>The other version can't be translated properly.
>As someone from a non-English speaking country, you should care.
from English import errorFormats as ef
print [ef.Err0, ef.Err1, ef.ErrN][(n>0)+(n>1)] % n
or what is Pythonic practice?
More information about the Python-list