I would do it in this way to make it look more like bash:
Just create a file named .pythonstartup at Home directory and use poke's answer in a function
On Linux:
echo "from subprocess import call
def clear(int=None):
call('clear')
if int == 0:
exit()
clear()" >> $HOME/.pythonstartup ; export PYTHONSTARTUP=$HOME/.pythonstartup ; python
You can add export PYTHONSTARTUP=$HOME/.pythonstartup
to your ./bashrc
file
Since what I care about is space; a call to the function will not display the python interpreter description at startup, but you can remove clear()
to retain it.
Using it like a normal function should do the trick without printing the exit status:
>>> clear()
If you pass the argument 0 to the function it will clear the screen and exit successfully so you can continue using the shell in a clean screen
>>> clear(0)