Paul Rubin wrote: > Tim Harig <user...@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.
Well, it depends on where you put the assert statement. If your code is like this: 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 assert self.lower <= self.higher then the assert statement is correct. Some people might prefer to keep all asserts at the top of function though. -- http://mail.python.org/mailman/listinfo/python-list