On Jun 28, 2011, at 6:25 AM, Karen Tracey wrote:

> It actually doesn't *need* to return False; pass is the same as not returning 
> anything or returning None. The boolean check just treats it the same way as 
> False. "Should it?" is another question. On the one hand it's a bit more 
> clear, this value is called and always returns False, unless a backend has 
> overridden it. On the other hand, pass is in keeping with other methods in 
> that class that are meant to be overridden in backends, so I went with pass 
> to emphasize that aspect of the code.
> 
> Hmm, well, I did not know that falling off the end of a method with pass 
> guaranteed a return value of False or None (and can't find that noted in the 
> doc here:http://docs.python.org/tutorial/controlflow.html#pass-statements) so 
> in my mind explicitly returning False would be clearer/better...

Ah, okay. To be clear, the return value actually has nothing to do specifically 
with the use of pass or not. The behavior of Python is to return None from any 
function that does not explicitly return a value. This is from the exact same 
page in the Python docs you linked to:

"In fact, even functions without a return statement do return a value, albeit a 
rather boring one. This value is called None (it’s a built-in name). Writing 
the value None is normally suppressed by the interpreter if it would be the 
only value written."

Obviously it's a fairly minor point but we want things to be as clear as 
possible. Anyone else wants to weigh in on "pass" vs. an explicit return value?

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to