Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I print to the console instead of an iPython output cell?

I want to print my output to the console (the one showing the log information or, better yet, a separate console) rather than an output cell in the iPython web notebook.

This is because I frequently have very long output I like to scroll through, and Chrome lags and breaks on large output, whereas iTerm2 does not.

like image 965
Nick Avatar asked Jul 06 '15 12:07

Nick


1 Answers

Update of the answer from valhallasw: You should use the following, otherwise it returns TypeError: a bytes-like object is required, not 'str'.

import os
os.write(1, b"text\n")

Otherwise, you can also do as Oliver Evans said:

import os
os.write(1, "text\n".encode())
like image 130
Astromax Avatar answered Sep 21 '22 13:09

Astromax