question of style

Tim Harig usernet at ilthio.net
Thu Jul 2 16:37:13 EDT 2009


On 2009-07-02, Paul Rubin <http> wrote:
[reformated with emphasis added]
>    #self.higher and self.lower are each either "available" (i.e.  are not
>    #None), or unavailable (are None).  [EMPHASIS] Return the highest of the
>    #available values. [/EMPHASIS]  If no value is available, return None.

Your code doesn't do what your comment says (notice EMPHASIS tags):

>    if self.higher is not None: 
>        return self.higher
>    elif self.lower is not None: 
>        return self.lower
>    else: 
>        return None

If lower is 5 and higher is 3, then it returns 3 because 3 != None in the
first if.



More information about the Python-list mailing list