On Wed, 26 Aug 2009 16:47:33 +1000, Ben Finney
wrote:
> "Nicola Larosa (tekNico)" writes:
>
>> Nicola Larosa wrote:
>> > Here's my take:
>> >
>> > excessblk = Block(total - P.BASE, srccol,
>> > carry_button_suppress=True
>> > ) if total > P.BASE else None
>>
>> Oops, it got shortened
"Nicola Larosa (tekNico)" writes:
> Nicola Larosa wrote:
> > Here's my take:
> >
> > excessblk = Block(total - P.BASE, srccol,
> > carry_button_suppress=True
> > ) if total > P.BASE else None
>
> Oops, it got shortened out: line longer than 72 chars, acceptable in
> code, but not in e
Nicola Larosa wrote:
> Here's my take:
>
> excessblk = Block(total - P.BASE, srccol,
> carry_button_suppress=True
> ) if total > P.BASE else None
Oops, it got shortened out: line longer than 72 chars, acceptable in
code, but not in email. I'll try again.
If the first line is too long,
John Posner wrote:
> Is there any consensus on how to format a conditional expression
> that is too long for one line?
Here's my take:
excessblk = Block(total - P.BASE, srccol,
carry_button_suppress=True
) if total > P.BASE else None
--
Nicola Larosa - http://www.tekNico.net/
Nobody
In article <87ocqchl2k@benfinney.id.au>,
Ben Finney wrote:
>"Diez B. Roggisch" writes:
>>
>> excessblk = None
>> if total > P.BASE:
>> excessblk = ...
>>
>> You don't lose any vertical space,
>
>I don't see vertical space as such a scarce resource; we don't have an
>imminent newline shor
Diez wrote:
No. I love them. But not if they are so large that they stretch over several
lines (or to many columns).
foo = bar if cond else baz
is more than fine for me. But
foo = I_need_to_do_something_really_complicated_here() if cond else baz
isn't, because one doesn't grasp as easily in
Richard Brodie a écrit :
"John Posner" wrote in message
news:mailman.26.1250604346.2854.python-l...@python.org...
if total > P.BASE:
excessblk = Block(total - P.BASE, srccol, carry_button_suppress=True)
else:
excessblk = None
I wonder if it is appropriate to replace the None sen
> BTW, from the (admittedly few) responses to my original post, it seems
> there's some sentiment that "conditional expressions" are a non-Pythonic
> misfeature. Interesting ...
No. I love them. But not if they are so large that they stretch over several
lines (or to many columns).
foo = bar if
On Aug 18, 1:25 pm, John Posner wrote:
> BTW, from the (admittedly few) responses to my original
> post, it seems there's some sentiment that "conditional
> expressions" are a non-Pythonic misfeature. Interesting ...
Well, it's not like Guido was especially eager to add it in the first
place.
I
John Posner writes:
> > excessblk = None
> > if total > P.BASE:
> > excessblk = ...
> >
[…]
> But doesn't it violate the DRY principle? The token "excessblk"
> appears twice instead of once.
No, the DRY principle http://c2.com/cgi/wiki?DontRepeatYourself>
doesn't speak against assigning two
"Diez B. Roggisch" writes:
> excessblk = None
> if total > P.BASE:
> excessblk = ...
>
> You don't lose any vertical space,
I don't see vertical space as such a scarce resource; we don't have an
imminent newline shortage, to my knowledge. I value it far lower than,
say, local readability.
>
John Posner writes:
> Is there any consensus on how to format a conditional expression that
> is too long for one line? How about this:
>
> excessblk = (Block(total - P.BASE, srccol, carry_button_suppress=True)
> if total > P.BASE else
> None)
>
> The above format sep
18-08-2009 Steven D'Aprano wrote:
On Tue, 18 Aug 2009 10:04:36 -0400, John Posner wrote:
[snip]
How about this:
excessblk = (Block(total - P.BASE, srccol, carry_button_suppress=True)
if total > P.BASE else
None)
If you insist on using the conditional expres
John Posner wrote:
BTW, from the (admittedly few) responses to my original post, it seems
there's some sentiment that "conditional expressions" are a non-Pythonic
misfeature. Interesting ...
-John
I didn't read it that way. One of the (to me) core points of Pythonic
is readability. A
I wonder if it is appropriate to replace the None sentinel with one that is an
instance
of Block() e.g.
size = total - P.BASE
excessblk = Block(size, srccol, carry_button_suppress=True, empty_block=(size
<= 0) )
In this particular case, Richard, I don't think so. The Block class is
an a
John Posner wrote:
My choice would be
excessblk = None
if total > P.BASE:
excessblk = ...
Diez and Jean-Michel,
Ha! Your suggestion above was my *original* coding. It looks like I'm
evolving backwards!
But doesn't it violate the DRY principle? The token "excessblk"
appears twice ins
"John Posner" wrote in message
news:mailman.26.1250604346.2854.python-l...@python.org...
> if total > P.BASE:
> excessblk = Block(total - P.BASE, srccol, carry_button_suppress=True)
> else:
> excessblk = None
I wonder if it is appropriate to replace the None sentinel with one that
My choice would be
excessblk = None
if total > P.BASE:
excessblk = ...
Diez and Jean-Michel,
Ha! Your suggestion above was my *original* coding. It looks like I'm
evolving backwards!
But doesn't it violate the DRY principle? The token "excessblk" appears
twice instead of once.
Than
On Tue, 18 Aug 2009 10:04:36 -0400, John Posner wrote:
> While refactoring some code, I ran across an opportunity to use a
> conditional expression. Original:
>
> if total > P.BASE:
> excessblk = Block(total - P.BASE, srccol,
> carry_button_suppress=True)
> else:
> excessblk
Diez B. Roggisch wrote:
John Posner wrote:
While refactoring some code, I ran across an opportunity to use a
conditional expression. Original:
if total > P.BASE:
excessblk = Block(total - P.BASE, srccol,
carry_button_suppress=True)
else:
excessblk = None
Is there any
John Posner wrote:
> While refactoring some code, I ran across an opportunity to use a
> conditional expression. Original:
>
> if total > P.BASE:
> excessblk = Block(total - P.BASE, srccol,
> carry_button_suppress=True)
> else:
> excessblk = None
>
> Is there any consensus
While refactoring some code, I ran across an opportunity to use a
conditional expression. Original:
if total > P.BASE:
excessblk = Block(total - P.BASE, srccol, carry_button_suppress=True)
else:
excessblk = None
Is there any consensus on how to format a conditional expression that i
22 matches
Mail list logo