Hello to you dear reader,
When doing python code, it might be useful to fire up the REPL (Read-Eval-Print-Loop) by simply typing
python in a terminal to test some expressions.
But the problem is that it is very barebone. No history, no modules loaded by default. I don't know about you but 99% of the time I'll need to use
pandas at the minimum. Probably
Who has time to type
import xyz every time? Not me.
So here is how to autoload modules in python's REPL:
As you can see, this file will also configure the
~/.pyhistory file so python doesn't forget everything when you close the REPL.
It is recommended to install these often used modules with
pip install --user module-name, see my previous post: Stop using sudo pip install
Add this to your ~/.zshrc, ~/.fishrc, ~/.bashrc or whatever you use:
# Note that '~' is not expanded, so use the full path here export PYTHONSTARTUP=/home/user/.pystartup
That's it, now try again to fire up
python and check that the modules are there.
There you go :) Now go write so amazing code!