[BangPypers] 2-cent Tip: Load modules at Startup

Amit Saha lists.amitsaha at gmail.com
Thu Oct 22 15:13:19 CEST 2009


I have been using CPython as a calculator, while I do all those number 
crunching in C. SO, 'import math' is a must.

This is what I did:

- Create a file: .pythonrc in my $HOME and place this line:

    import math

- Now in your BASH, .bashrc or similar: export PYTHONSTARTUP= 

Everytime you start Python interactively, you should have the 'math' 
module already imported.


$ python
Python 2.6.4rc1 (r264rc1:75270, Oct 10 2009, 02:40:56)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> math.pi


Hope this helps.

Journal: http://amitksaha.wordpress.com
µ-blog: http://twitter.com/amitsaha
IRC: cornucopic on #scheme, #lisp, #math, #linux

More information about the BangPypers mailing list