Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #41425

Re: What are some other way to rewrite this if block?

References <CAE7MaQabqa2DT6bfiq3Ju1Kfyq2dMLFvebk3ynFbZnHxTSqsHA@mail.gmail.com>
Date 2013-03-18 19:49 +0530
Subject Re: What are some other way to rewrite this if block?
From Laxmikant Chitare <laxmikant.general@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.3453.1363616383.2939.python-list@python.org> (permalink)

Show all headers | View raw


What about this one:
if 0.0 < should_be_on > 24.0 or 0.0 < came_on > 24.0:

Regards,
Laxmikant

On 3/18/13, Santosh Kumar <sntshkmr60@gmail.com> wrote:
> This simple script is about a public transport, here is the code:
>
> def report_status(should_be_on, came_on):
>     if should_be_on < 0.0 or should_be_on > 24.0 or came_on < 0.0 or
> came_on > 24.0:
>         return 'time not in range'
>     elif should_be_on == came_on:
>         return 'on time'
>     elif should_be_on > came_on:
>         return 'early'
>     elif should_be_on < came_on:
>         return 'delayed'
>     else:
>         return 'something might be wrong'
>
> print(report_status(123, 12.0))
>
> I am looking forward of make the line starting with `if` short.
>
> Any tips are welcome.
> --
> http://mail.python.org/mailman/listinfo/python-list
>

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: What are some other way to rewrite this if block? Laxmikant Chitare <laxmikant.general@gmail.com> - 2013-03-18 19:49 +0530

csiph-web