[Tutor] No return statement
ebbaalm at uiuc.edu
Tue Apr 24 20:05:10 CEST 2007
OK, that's my opinion too.
2007/4/24, Andre Engels <andreengels at gmail.com>:
> My opinion is that one should not create or set a variable if its
> value is not used. In the case mentioned, you know what the return
> value will be, so there seems to be no reason to keep it.
> 2007/4/24, Cecilia Alm <ebbaalm at uiuc.edu>:
> > My apologies for asking a trivial question about programming practice.
> > As mentioned in the online tutorial
> > (http://docs.python.org/tut/node6.html#SECTION006700000000000000000),
> > functions which lack a return statement ('procedures') actually return "None".
> > For such functions, I assume it's preferred to not catch "None" in a variable.
> > Example:
> > >>> def printme(x):
> > print x
> > Preferred function call:
> > >>> printme(10)
> > 10
> > Alternative (where None is caught into z):
> > >>> z = printme(10)
> > 10
> > (And then one could print None)
> > >>> print z
> > None
> > _______________________________________________
> > Tutor maillist - Tutor at python.org
> > http://mail.python.org/mailman/listinfo/tutor
> Andre Engels, andreengels at gmail.com
> ICQ: 6260644 -- Skype: a_engels
E. Cecilia Alm
Graduate student, Dept. of Linguistics, UIUC
Office: 2013 Beckman Institute
More information about the Tutor