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


Groups > comp.lang.python > #41425 > unrolled thread

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

Started byLaxmikant Chitare <laxmikant.general@gmail.com>
First post2013-03-18 19:49 +0530
Last post2013-03-18 19:49 +0530
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

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

FromLaxmikant Chitare <laxmikant.general@gmail.com>
Date2013-03-18 19:49 +0530
SubjectRe: What are some other way to rewrite this if block?
Message-ID<mailman.3453.1363616383.2939.python-list@python.org>
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
>

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web