Wednesday, January 1, 2014

Python tip[2]

Tip #2

In your home directory, in a file named put the imports you want to always have preloaded in python interactive mode:
from some_module import something
In your .bashrc or .profile, add:
What it does: When you login and open a terminal, the environment variable PYTHONSTARTUP will be set, and when you execute python (or bpython, too), the python interpreter will load whatever scripts are in PYTHONSTARTUP and be ready for you to use them without having to type them everytime. In this example, I could use functionality something of some_module right away.


1 comment:

Jonny Smith said...

iMOBDEV team really appreciates this a lot. Keep sharing interesting facts on your next blog.

Android Application Development