newbie - How do I import automatically?

Mikael Olofsson mikael at isy.liu.se
Thu Nov 17 02:44:19 EST 2005


bobueland at yahoo.com wrote:
> I tried to put the line
> from btools import *
> in several places in PyShell.py
> but to now avail. It does not work, IDLE does not execute it???

IDLE definitely executes PyShell.py upon startup, since IDLE does not 
even appear on the screen if there is an error in that file. The 
following seems to work for me, in PyShell.py. After importing both sys 
and os,

sys.modules['__main__'].__dict__['os'] = os

Then, if I start IDLE, the module os is directly available.

HTH
/MiO



More information about the Python-list mailing list