The Samurai Principle
steve at REMOVE-THIS-cybersource.com.au
Sun Sep 12 09:55:01 CEST 2010
On Sun, 12 Sep 2010 12:08:26 +1200, Lawrence D'Oliveiro wrote:
>> And that is exactly the reason why the Samurai Principle says to not
>> return None when the function fails to do what it intended to do.
> How can the function “fail” when it returns what it is specified to
Are you trolling?
On the unlikely event that you're not, if you have a function called
"len", the *intent* of the function is to return the length of its
argument. That's why it's called "len" rather than "raise_exception" or
The use of the term "fail" is entirely unexceptional here. It is normal
English to say such things as "the function re.match() returns None if
the regular expression fails to match" or "if we fail to acquire a lock,
raise an Exception".
More information about the Python-list