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