Code formatting question: conditional expression
Nicola Larosa (tekNico)
nicola.larosa at gmail.com
Wed Aug 26 01:54:59 EDT 2009
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 would write it like this:
excessblk = Block(total - P.BASE, srccol,
carry_button_suppress=True) if total > P.BASE else None
If not, like this:
excessblk = Block(total - P.BASE, srccol, cbs=True
) if total > P.BASE else None
If the condition or the last value were too long to make it all fit on
two lines, then it would probably best to revert to a plain "if"
statement.
--
Nicola Larosa - http://www.tekNico.net/
More information about the Python-list
mailing list