Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.027 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.01; 'else:': 0.03; 'elif': 0.04; 'welcome.': 0.07; 'def': 0.10; "range'": 0.16; "time'": 0.16; 'script': 0.24; 'message-id:@mail.gmail.com': 0.27; 'subject:other': 0.29; 'subject:some': 0.29; 'to:addr:python- list': 0.33; 'code:': 0.33; 'received:google.com': 0.34; 'subject:?': 0.35; 'skip:p 20': 0.36; 'to:addr:python.org': 0.39; 'here': 0.65; 'forward': 0.66; 'subject:this': 0.84; 'transport,': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=RmC+5rkpjLuubgACTLRRBbz9NqOPG4T6bIuE7bRUpII=; b=F+nWSf6JhdObiP2XVloNt4l2JPD0koLsNcUj9h/DI5r1eXOOztWlLfZKJpD1Zn+qVN eZqhCfEN0f79Zqo7N7eKsZb4tELkRIVc4aogAIfC4CPmD2fXXafyJTcALj7TdQvq3hKI IopMkkL+XLOO8sAB+ml7AzvmhKs97l4+3J3eXmh4jP7BPRNpbAHdOX7mot8TCKSVQySK SCw3whtl5w7dW2u2/pkrpZbjBDWWv4JWwmL6DHkFwjTYPqhNNw6PNRFGf/qXtNkdA+Kl A9fcBvedCqpXGJ0x/X6Nt5y4WOWM+1XYlDggjgCPEGIh4WWZoEIwwoe5+yhC+HJVBfKv WivA== MIME-Version: 1.0 X-Received: by 10.152.110.6 with SMTP id hw6mr14828787lab.43.1363614976165; Mon, 18 Mar 2013 06:56:16 -0700 (PDT) Date: Mon, 18 Mar 2013 19:26:16 +0530 Subject: What are some other way to rewrite this if block? From: Santosh Kumar To: python-list@python.org Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1363614983 news.xs4all.nl 6951 [2001:888:2000:d::a6]:38788 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:41415 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.