[Tutor] Suppressing output in interactive mode
Alan Gauld
alan.gauld at btinternet.com
Fri Jan 11 21:11:31 CET 2008
"Olivier Lefevre" <lefevrol at yahoo.com> wrote
>> But if you refer to a loop when would you ever be evaluating
>> expressions inside a loop without assigning them?
>
> Some method calls return a value that you may not be interested
> in but which will still be printed, e.g., Set.add in Java (if
> you are using jython, this is relevant).
OK, I see. Interestingly default retuirn values are not printed:
>>> def f(n): return
...
>>> for n in range(5):
... f(n)
...
>>>
But if they return printable values then yes you would see them.
In that case I'd just assign to a dummy variable.
But usually in the >>>> prompt I don't care, if there were so
many lines inside a loop I'd probably create a test file for the
code because its easier to edit changes.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld
More information about the Tutor
mailing list