Search code examples
ipythonsuppression

A semicolon to suppress output does not work in IPython


In the documentation at IPython Tips & Tricks, it says to put a semicolon (;) at the end of a command to suppress its output. This does not seem to work in my case as even a

print('Hello');

outputs

Hello

Do I have the wrong idea of output suppression or is this a bug? This is especially annoying when working in PuDB, as it flashes horribly in my case as I press 'next' or 'step into'.

P.S.: The output is neither on my Ubuntu IPython 0.10 nor OS X v10.7 (Lion) IPython 0.11 suppressed. Although the flashing issue is worse in OS X, probably because of item2.


Solution

  • Try something like 1 + 1;. Without the semicolon, it should give you feedback about the result by printing it (formatted by repr, though it doesn't matter in the case of integers) - I assume that it's this output that's supposed to be suppressed.

    The shell doesn't (and shouldn't) suppress writing to the file that happens to be referenced by sys.stdout (which is essentially what print does). This is an entirely different matter, and not the job of the shell.