On Wed, Sep 19, 2012 at 09:08:52AM +0200, Penguin Lover Marc Joliet squawked: > 2.) The full blown interactive solution: IPython. You can create a session and > configure which modules you want preloaded via startup scripts. This is > overkill for what you want, I think, but IPython is a much nicer interactive > Python interpreter than python itself. For instance, you can reuse previous > outputs, e.g. "Out[2]", to get the output from the third command you entered > (indexing starts at 0). Inputs can be similarly recalled by referencing > "In[i]".
Yes, I recommend ipython too. > 3.) Put the "import" line in its own file and put it in the variable > PYTHONSTARTUP, e.g. "export PYTHONSTARTUP=/path/to/my/script.py". Python > executes it's contents before presenting the prompt, so you can put whatever > imports you want in that script. It's simple, and if the python interpreter is > enough for you, then I'd go with this. > > There are probably more possibilities, but this is what I can think of right > now. Unless you want to load the math module every single time you start Python, it is perhaps better to create an alias (say, python-calc) in bash (or shell of your choice) using the `-i' option of python like alias python-calc='python -i loadmath.py' or if you only need one single command alias python-calc='python -i -c "from math import *"' which will give you an interactive session with the math functions preloaded. Cheers, W -- Data aequatione quotcunque fluentes quantitae involvente fluxiones invenire et vice versa ~~~ I. Newton