question of style

Paul Rubin http
Thu Jul 2 18:32:27 EDT 2009


Tim Harig <usernet at ilthio.net> writes:
> 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.

Well, that assert is not right because you have to handle the case
where one of the values is None.  The general sentiment is reasonable
though, if you're concerned that the precondition may not be valid.



More information about the Python-list mailing list