Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start Python REPL quietly?

Is there a way to startup python quietly, perhaps by setting some environment variable or supplying command line option? Instead of seeing this:

wim@SDFA100461C:/tmp$ python
Python 2.7.5+ (default, Sep 19 2013, 13:48:49) 
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Sometimes I want this behaviour, straight to the prompt:

wim@SDFA100461C:/tmp$ python
>>> 

I would also be interested in an answer for ipython.

like image 948
wim Avatar asked Jan 06 '14 10:01

wim


1 Answers

This seems to do the trick:

C:\Users\Bartek>python -i -c ""
>>> print "I ♥ Python!"
I ♥ Python!
>>> exit()

C:\Users\Bartek>

The -i option is described as:

-i : inspect interactively after running script; forces a prompt even if stdin does not appear to be a terminal; also PYTHONINSPECT=x

So as long as you're on a terminal, it doesn't seem to have any caveats.

ipython has a straightforward --no-banner option:

C:\Users\Bartek>ipython --no-banner

In [1]: print "I <3 Python!"
I <3 Python!

In [2]: exit()

C:\Users\Bartek>

It doesn't seem to support Unicode though ;)

like image 192
BartoszKP Avatar answered Nov 19 '22 03:11

BartoszKP