PEP new assert idiom

Alex Martelli aleaxit at yahoo.com
Sun Nov 7 08:30:35 CET 2004


Fábio Mendes <niels_bohr at uol.com.br> wrote:
   ...
> > called, would differ from those of
> > 
> > assert exp1 and exp2 and exp3 ... and expN, 'errormsg'
> 
> This is very similar to what I'm proposing, with the only inconvinience
> that is uglier to type:
> 
> assert \
>   exp1 and \
>   exp2 and \
>   ...
>   expn,
>   'ErrorMsg'
> 
> Instead of:
> 
> assert \
>   exp1,
>   exp2,
>   ...
>   expn,
>   'Errormsg'

So follow PEP 8's recommendation instead:

assert (
   exp1 and
   exp2 and
   ...
   expn
   ), 'Errormsg'

I don't see the parentheses (which clarify the syntax issue you
mentioned in your first post) and 'and' as any uglier than the commas.
And having commas mean line continuation is out of the question.


Alex



More information about the Python-list mailing list