Thanks Karen..
Did not realize that "Running of the end of the code" in python
results in returning a None and not the last evaluated expression.
I wrote a small test case and realized what you said that without an
explicit return , python returns a None even though the evaluated
expression returns something. Makes a lot of sense
Thanks again
def func2(arg):
print "func2 called"
x = "Give me an arg"
return x
def func1(arg=None):
if arg != None:
x = "Thanks"
return x
else:
func2(arg)
if __name__=="__main__":
print "Calling first func with argument"
x = func1("hello")
print x
print "Calling first func without argument"
x = func1()
print x
On Jan 18, 7:40 am, Karen Tracey <[email protected]> wrote:
> On Sun, Jan 17, 2010 at 11:47 PM, Benjamin Welton <
>
> [email protected]> wrote:
> > Since the call structure goes similar to this Django Internals ->
> > view_func1 -> authenticate_user. That return is required so that the Django
> > internals see the HttpResponse Class. Without this return all thats passed
> > back to django is None.
>
> To clarify, it is Python the language, not Django, that requires an explicit
> return value. In Python, if a function or method wants to return something
> other than None, it much have an explicit return specifying what is to be
> returned. "Running off the end of the code" results in the function/method
> returning None, not (as in some languages) the value of the last evaluated
> expression.
>
> Karen
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.