Re: python syntax for conditional is unfortunate

2008-09-24 Thread Aaron "Castironpi" Brady
On Sep 24, 9:49 pm, Asun Friere <[EMAIL PROTECTED]> wrote: > On Sep 25, 11:57 am, "Aaron \"Castironpi\" Brady" > > <[EMAIL PROTECTED]> wrote: > > On Sep 24, 8:40 pm, Asun Friere <[EMAIL PROTECTED]> wrote: > > > ... I think > > > your last version ('%d thing%s' % (i, 's' if i != 1 else '')), holding

Re: python syntax for conditional is unfortunate

2008-09-24 Thread Asun Friere
On Sep 25, 11:57 am, "Aaron \"Castironpi\" Brady" <[EMAIL PROTECTED]> wrote: > On Sep 24, 8:40 pm, Asun Friere <[EMAIL PROTECTED]> 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 certa

Re: python syntax for conditional is unfortunate

2008-09-24 Thread Aaron "Castironpi" Brady
On Sep 24, 8:40 pm, Asun Friere <[EMAIL PROTECTED]> wrote: > On Sep 25, 3:16 am, Pete Forman <[EMAIL PROTECTED]> wrote: > > > Asun Friere <[EMAIL PROTECTED]> writes: > > >  > A canonical use of the conditional operator is in > >  > pluralising words, (eg. '%s dollar' % n + 's' if n!=1 else ''). > >

Re: python syntax for conditional is unfortunate

2008-09-24 Thread Asun Friere
On Sep 25, 3:16 am, Pete Forman <[EMAIL PROTECTED]> wrote: > Asun Friere <[EMAIL PROTECTED]> writes: > > > A canonical use of the conditional operator is in > > pluralising words, (eg. '%s dollar' % n + 's' if n!=1 else ''). > > That fails for n == 1. So what is best? > Sorry missing paranthese

Re: python syntax for conditional is unfortunate

2008-09-24 Thread Asun Friere
On Sep 25, 3:16 am, Pete Forman <[EMAIL PROTECTED]> wrote: > Asun Friere <[EMAIL PROTECTED]> writes: > > > A canonical use of the conditional operator is in > > pluralising words, (eg. '%s dollar' % n + 's' if n!=1 else ''). > > That fails for n == 1. So what is best? > Sorry missing parenthese

Re: python syntax for conditional is unfortunate

2008-09-24 Thread Pete Forman
Asun Friere <[EMAIL PROTECTED]> writes: > A canonical use of the conditional operator is in > pluralising words, (eg. '%s dollar' % n + 's' if n!=1 else ''). That fails for n == 1. So what is best? for i in range(4): print '%d thing' % i + ('s' if i != 1 else '') for i in range(4): p

Re: python syntax for conditional is unfortunate

2008-09-24 Thread Asun Friere
On Sep 24, 9:52 am, Neal Becker <[EMAIL PROTECTED]> wrote: > In hindsight, I am disappointed with the choice of conditional syntax. I > know it's too late to change. The problem is > > y = some thing or other if x else something_else > > When scanning this my eye tends to see the first phrase an

Re: python syntax for conditional is unfortunate

2008-09-24 Thread Bruno Desthuilliers
Neal Becker a écrit : (snip) I find I'm often tripped up by: x = Y (lots of constructor arguments) if something ... on first glance, I don't notice the if. Indeed. The inline conditionnal syntax is obviously innappropriate here. It's just like list-comprehensions : just fine for simple

Re: python syntax for conditional is unfortunate

2008-09-23 Thread Roy Smith
"Aaron \"Castironpi\" Brady" <[EMAIL PROTECTED]> wrote: > You're out of options. You have to express it somehow. How about: Assignith z the value of x if the value of b is such that it is true, else assignith it the value of y. Assignith z not the value of w, nor the value of v, lest you ra

Re: python syntax for conditional is unfortunate

2008-09-23 Thread namekuseijin
On 23 set, 22:50, Neal Becker <[EMAIL PROTECTED]> wrote: > I find I'm often tripped up by: > > x = Y (lots of  constructor arguments) if something ... > > on first glance, I don't notice the if. Nobody does. This peculiar syntax has much better usage in short expressions. dothis if this else

Re: python syntax for conditional is unfortunate

2008-09-23 Thread Aaron "Castironpi" Brady
On Sep 23, 8:50 pm, Neal Becker <[EMAIL PROTECTED]> wrote: > Aaron "Castironpi" Brady wrote: > > On Sep 23, 6:52 pm, Neal Becker <[EMAIL PROTECTED]> wrote: > >> In hindsight, I am disappointed with the choice of conditional syntax.  I > >> know it's too late to change.  The problem is > > >> y = so

Re: python syntax for conditional is unfortunate

2008-09-23 Thread Neal Becker
Aaron "Castironpi" Brady wrote: > On Sep 23, 6:52 pm, Neal Becker <[EMAIL PROTECTED]> wrote: >> In hindsight, I am disappointed with the choice of conditional syntax. I >> know it's too late to change. The problem is >> >> y = some thing or other if x else something_else >> >> When scanning this

Re: python syntax for conditional is unfortunate

2008-09-23 Thread namekuseijin
On 23 set, 20:52, Neal Becker <[EMAIL PROTECTED]> wrote: > In hindsight, I am disappointed with the choice of conditional syntax.  I > know it's too late to change.  The problem is > > y = some thing or other if x else something_else > > When scanning this my eye tends to see the first phrase and

Re: python syntax for conditional is unfortunate

2008-09-23 Thread Aaron "Castironpi" Brady
On Sep 23, 6:52 pm, Neal Becker <[EMAIL PROTECTED]> wrote: > In hindsight, I am disappointed with the choice of conditional syntax.  I > know it's too late to change.  The problem is > > y = some thing or other if x else something_else > > When scanning this my eye tends to see the first phrase an

Re: python syntax for conditional is unfortunate

2008-09-23 Thread Ben Finney
Cameron Simpson <[EMAIL PROTECTED]> writes: > A good coder will present things clearly. For trivial stuff the one > line form may be fine, and for longer stuff then this: > > y = some thing or other \ > if x \ > else something_else Parentheses are usually more robust for multi-line

Re: python syntax for conditional is unfortunate

2008-09-23 Thread Cameron Simpson
On 23Sep2008 19:52, Neal Becker <[EMAIL PROTECTED]> wrote: | In hindsight, I am disappointed with the choice of conditional syntax. | I know it's too late to change. The problem is | | y = some thing or other if x else something_else | | When scanning this my eye tends to see the first phrase an