python syntax for conditional is unfortunate

Asun Friere afriere at yahoo.co.uk
Wed Sep 24 22:49:48 EDT 2008


On Sep 25, 11:57 am, "Aaron \"Castironpi\" Brady"
<castiro... at gmail.com> wrote:
> On Sep 24, 8:40 pm, Asun Friere <afri... at yahoo.co.uk> wrote:
> > ... I think
> > your last version ('%d thing%s' % (i, 's' if i != 1 else '')), holding
> > all variables for placeholders in the tuple, is better. It's certainly
> > more readible.
>
> It's a different answer if you have 'things is/are'.  '%d thing%s %s'%
> ( ( i, )+ ( 's', 'are' ) if i!= 1 else ( '', 'is' ) ).  Or excluding
> prepositional phrases and subordinate clauses, '%d thing%s'% ( i, 's
> are' if i!= 1 else ' is' ).

Forgive me for being dull, my caffeine levels have not yet optimal,
but I don't follow.  Both the solutions you propose do put all the
placeholder variables in the tuple.  Or are you saying it no longer
remains readible?

BTW you repeated my mistake with the first scraplet of code.




More information about the Python-list mailing list