Nicola Larosa (tekNico) nicola.lar...@gmail.com 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
On Wed, 26 Aug 2009 16:47:33 +1000, Ben Finney
ben+pyt...@benfinney.id.au wrote:
Nicola Larosa (tekNico) nicola.lar...@gmail.com writes:
Nicola Larosa wrote:
Here's my take:
excessblk = Block(total - P.BASE, srccol,
carry_button_suppress=True
) if total P.BASE else None
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
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, I
In article 87ocqchl2k@benfinney.id.au,
Ben Finney ben+pyt...@benfinney.id.au wrote:
Diez B. Roggisch de...@nospam.web.de 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
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 cond
Richard Brodie a écrit :
John Posner jjpos...@optimum.net 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
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
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
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 on how to
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
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 = None
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.
Thanks
John Posner jjpos...@optimum.net 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
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
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
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
18-08-2009 Steven D'Aprano st...@remove-this-cybersource.com.au 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
John Posner jjpos...@optimum.net 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
Diez B. Roggisch de...@nospam.web.de 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
On Aug 18, 1:25 pm, John Posner jjpos...@optimum.net 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
21 matches
Mail list logo