newbie: suppressing return values

Andrew Bennetts andrew-pythonlist at puzzling.org
Wed Dec 3 21:56:02 EST 2003


On Wed, Dec 03, 2003 at 07:41:13PM -0700, Jim Benson wrote:
[...]
> 
> In mathematica one can put a ; at the end of
> a function call and the output is suppressed.
> In this example if python behaved like mathematica in 
> this case one would see:
> 
> >>> makeList();
> >>>
> >>> makeList()
> [1, 2, 3]
> >>>
> 
> Is there a simple way (other than the a = makeList())
> to do this "suppression" in python?

You could do:

    import sys
    sys.displayhook = lambda x: None

But that will turn it off indefinitely, rather than on a line-by-line basis,
which seems to be what you're after...

-Andrew.






More information about the Python-list mailing list