newbie - How do I import automatically?

Brett Hoerner bretthoerner at gmail.com
Tue Nov 15 21:15:47 CET 2005


> I have written some functions in a file called btools.py. I would like
> to import them automatically when I start up Python shell. Today I must
> do it by hand like this
>
> >>> from btools import *
> >>> dir()
> ['__builtins__', '__doc__', '__name__', 'func1', 'func2', 'func3']
> >>>
>
> Is there a way to do this automatically so that I always have 'func1',
> 'func2' and so on available, without me having to do it by hand?

This isn't _exactly_ what you wanted, but you might want to try using
IPython, a much improved Python shell,

http://ipython.scipy.org/

You can easily configure it to automatically import whatever kind of
modules you want on start, etc... and it has many other features, I
just can't picture touching the normal Python shell anymore.




More information about the Python-list mailing list