[Tutor] return, why do I need it?

Pete O'Connell pedrooconnell at gmail.com
Sun Dec 11 15:38:47 CET 2011


Hi I have been writing python code for a while now and I never return
anything within any of my functions, I just (eg.) print stuff or make
directories or update a log or what have you. When I look at other people's
code they are always returning in their functions and I was wondering if
someone could give me an example of when I would absolutely have to return
something. The thing I don't like about returning is that when I unindent a
function and try to run the code to inspect parts of it for debugging I
always have to alter the code so as not to get the "return not inside a
function error",  so I will change the word "return" to "print" and in many
cases that's the way I leave it. Anyone have any thoughts on this?

Thanks
Pete
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111212/37874e83/attachment.html>


More information about the Tutor mailing list