Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python
question of style
 

Index | Next | Previous | View Flat


sajmikins at gmail

Jul 2, 2009, 10:23 AM


Views: 669
Permalink
question of style

Hey I was hoping to get your opinions on a sort of minor stylistic
point.
These two snippets of code are functionally identical. Which would you
use and why?
The first one is easier [for me anyway] to read and understand, but
slightly less efficient, while the second is [marginally] harder to
follow but more efficient.

## First snippet

if self.higher is self.lower is None: return
if self.lower is None: return self.higher
if self.higher is None: return self.lower

## Second snippet

if self.higher is None:
if self.lower is None:
return
return self.lower
if self.lower is None:
return self.higher

What do you think?

(One minor point: in the first snippet, the "is None" in the first
line is superfluous in the context in which it will be used, the only
time "self.lower is self.higher" will be true is when they are both
None.)
--
http://mail.python.org/mailman/listinfo/python-list

Subject User Time
question of style sajmikins at gmail Jul 2, 2009, 10:23 AM
    Re: question of style duncan.booth at invalid Jul 2, 2009, 10:44 AM
        Re: question of style sajmikins at gmail Jul 2, 2009, 10:58 AM
        Re: question of style usernet at ilthio Jul 2, 2009, 12:16 PM
        Re: question of style Scott.Daniels at Acm Jul 2, 2009, 12:57 PM
            Re: question of style usernet at ilthio Jul 2, 2009, 1:27 PM
                Re: question of style lie.1296 at gmail Jul 2, 2009, 11:05 PM
                    Re: question of style lie.1296 at gmail Jul 2, 2009, 11:37 PM
            Re: question of style sajmikins at gmail Jul 2, 2009, 4:13 PM
        Re: Re: question of style davea at ieee Jul 4, 2009, 6:31 AM
    Re: question of style kee at kagi Jul 2, 2009, 11:12 AM
    Re: question of style tjreedy at udel Jul 2, 2009, 11:53 AM
    Re: question of style http://phr.cx at NOSPAM Jul 2, 2009, 12:13 PM
        Re: question of style lie.1296 at gmail Jul 2, 2009, 11:33 PM
            Re: question of style http://phr.cx at NOSPAM Jul 3, 2009, 12:27 AM
                Re: question of style lie.1296 at gmail Jul 3, 2009, 1:06 AM
    Re: question of style http://phr.cx at NOSPAM Jul 2, 2009, 1:02 PM
        Re: question of style usernet at ilthio Jul 2, 2009, 1:37 PM
            Re: question of style http://phr.cx at NOSPAM Jul 2, 2009, 2:43 PM
                Re: question of style usernet at ilthio Jul 2, 2009, 3:14 PM
                    Re: question of style http://phr.cx at NOSPAM Jul 2, 2009, 3:32 PM
                        Re: question of style usernet at ilthio Jul 2, 2009, 3:49 PM
                            Re: question of style usernet at ilthio Jul 2, 2009, 3:56 PM
                            Re: question of style http://phr.cx at NOSPAM Jul 2, 2009, 5:57 PM
                        Re: question of style lie.1296 at gmail Jul 2, 2009, 11:40 PM
                    Re: question of style steve at REMOVE-THIS-cybersource Jul 3, 2009, 1:18 AM
                        Re: question of style usernet at ilthio Jul 3, 2009, 2:07 AM
    Re: question of style max at alcyone Jul 2, 2009, 1:08 PM
        Re: question of style sajmikins at gmail Jul 2, 2009, 4:04 PM
    Re: question of style http://phr.cx at NOSPAM Jul 2, 2009, 6:30 PM
        Re: question of style sajmikins at gmail Jul 2, 2009, 8:54 PM
    Re: question of style http://phr.cx at NOSPAM Jul 2, 2009, 9:56 PM
        Re: question of style steve at REMOVE-THIS-cybersource Jul 3, 2009, 12:50 AM
        Re: question of style sajmikins at gmail Jul 3, 2009, 1:17 PM
    Re: question of style lie.1296 at gmail Jul 2, 2009, 11:09 PM
        Re: question of style sajmikins at gmail Jul 3, 2009, 1:04 PM
    Re: question of style lie.1296 at gmail Jul 2, 2009, 11:47 PM
    Re: question of style jeanmichel at sequans Jul 3, 2009, 3:33 AM
    Re: question of style http://phr.cx at NOSPAM Jul 3, 2009, 1:50 PM
        Re: question of style gallium.arsenide at gmail Jul 3, 2009, 4:26 PM
        Re: question of style steve at REMOVE-THIS-cybersource Jul 3, 2009, 7:04 PM
            Re: question of style http://phr.cx at NOSPAM Jul 5, 2009, 6:12 AM
                Re: question of style steve at REMOVE-THIS-cybersource Jul 5, 2009, 9:20 AM
        Re: question of style aahz at pythoncraft Jul 3, 2009, 9:47 PM
            Re: question of style http://phr.cx at NOSPAM Jul 4, 2009, 6:29 AM
                Re: question of style aahz at pythoncraft Jul 4, 2009, 8:48 AM
    Re: question of style upwestdon at gmail Jul 3, 2009, 11:03 PM
    Re: question of style Scott.Daniels at Acm Jul 4, 2009, 5:28 AM
    Re: question of style sajmikins at gmail Jul 4, 2009, 7:54 AM
    Re: question of style http://phr.cx at NOSPAM Jul 4, 2009, 11:10 AM
        Re: question of style sajmikins at gmail Jul 4, 2009, 1:05 PM
        Re: question of style steve at REMOVE-THIS-cybersource Jul 4, 2009, 6:36 PM
            Re: question of style http://phr.cx at NOSPAM Jul 4, 2009, 11:17 PM
                Re: question of style steve at REMOVE-THIS-cybersource Jul 5, 2009, 2:04 AM
                    Re: question of style http://phr.cx at NOSPAM Jul 5, 2009, 3:08 AM
                        Re: question of style lie.1296 at gmail Jul 5, 2009, 4:37 AM
                            Re: question of style steve at REMOVE-THIS-cybersource Jul 5, 2009, 9:13 AM
                                Re: question of style lie.1296 at gmail Jul 5, 2009, 9:43 AM
                        Re: question of style steve at REMOVE-THIS-cybersource Jul 5, 2009, 9:00 AM
                            Re: question of style http://phr.cx at NOSPAM Jul 5, 2009, 3:51 PM
                                Re: question of style albert at spenarnc Jul 13, 2009, 7:46 PM
                        Re: question of style tjreedy at udel Jul 5, 2009, 12:09 PM
        Re: question of style albert at spenarnc Jul 13, 2009, 7:28 PM
    Re: question of style http://phr.cx at NOSPAM Jul 5, 2009, 3:53 PM
    Re: question of style piet at cs Jul 17, 2009, 1:12 AM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.