Boris Borcic a écrit : > Slawomir Nowaczyk wrote: > >> >> try: >> if int(text) > 0: >> return True >> except ValueError: >> pass >> self.error_message() >> return False >> > > Nicely DRY. To make it even more compact, it may be noticed that the > default return value None is false in a boolean context - so that the > last line is superfluous if the return value is only wanted to test it > in such a context.
While it's technically true - and I while I have a taste for compactness - skipping the explicit 'return False' somehow hurts my sense of esthethic... Unless you propose to return object or type instead of True - but then it begins to look very strange !-) -- http://mail.python.org/mailman/listinfo/python-list