question of style

Tim Harig usernet at ilthio.net
Thu Jul 2 18:14:18 EDT 2009


On 2009-07-02, Paul Rubin <http> wrote:
> Tim Harig <usernet at ilthio.net> writes:
>> If lower is 5 and higher is 3, then it returns 3 because 3 != None in the
>> first if.
> Sorry, the presumption was that lower <= higher, i.e. the comparison
> had already been made and the invariant was enforced by the class
> constructor.  The comment should have been more explicit, I guess.

That being the case, it might be a good idea either to handle the situation
and raise an exception or add:

assert self.lower <= self.higher

That way an exception will be raised if there is an error somewhere else
in the code rather then silently passing a possibly incorrect value.



More information about the Python-list mailing list