What are some other way to rewrite this if block?

Jussi Piitulainen jpiitula at ling.helsinki.fi
Mon Mar 18 10:53:51 EDT 2013


Duncan Booth writes:
> Jussi Piitulainen wrote:
> 
> >> Any tips are welcome.
> > 
> > A double tip:
> > 
> > if (not (0.0 <= should_be_on <= 24.0) or
> >     not (0.0 <= came_on <= 24.0)):
> >    ...
> > 
> Or even:
> 
>     if not (0.0 <= should_be_on <= 24.0 and 0.0 <= came_on <= 24.0):
>         ...

I'd still prefer to split the line, especially considering the fact
that the request was to make the line shorter:

if not (0.0 <= should_be_on <= 24.0 and
        0.0 <= came_on <= 24.0):
   ...



More information about the Python-list mailing list