When debugging, I often drop into an IPython shell for interactive code testing. However this also causes a large info dump of the python version, date and help instructions to stdout. How can I suppress this information so it doesn't obscure the intentional debugging messages?
x = get_important_data()
print 'important info! right here! The data is in variable "x"'
import IPython
IPython.embed()
This code gives output like this...
important info! right here! The data is in variable "x"
Python 2.7.11 |Anaconda 2.4.0 (x86_64)| (default, Dec 6 2015, 18:57:58)
Type "copyright", "credits" or "license" for more information.
IPython 4.0.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]:
You can do this:
IPython.embed(banner1="")
Setting banner1
to empty string would make the startup messages go away. It will not actually remove the messages but will replace them with empty strings.
You can also add useful messages using the banner1
, banner2
and exit_msg
parameters:
IPython.embed(
banner1="Entering Debug Mode",
banner2="Here's another helpful message",
exit_msg="Exiting the debug mode!"
)
If you ever need to launch IPython instance from the command line, you can do this:
ipython --no-banner
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With