[Edu-sig] Interactive interpreter: expressions vs. statements

Terry Hancock hancock@anansispaceworks.com
Sat, 15 Feb 2003 01:04:03 -0800


On Friday 14 February 2003 11:54 pm, Ka-Ping Yee wrote:
>     2.  Confusion about return vs. print.
> 
> I'd like to know whether any of you have encountered these
> problems before, how frequently they turn up, and how you have
> dealt with them.

Seems to me the only thing to do is to show a few alternate cases, such as 
assigning a function result to a variable:

>>> def pfunc():
...     print 'a'
... 
>>> def rfunc():
...     return 'a'
... 
>>> pfunc()
a
>>> a = pfunc()
a
>>> rfunc()
'a'
>>> b = rfunc()
>>> a
>>> b
'a'
>>> 

(There's also the point about the quoting here).

Cheers,
Terry

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com

"Some things are too important to be taken seriously"