newbie - How do I import automatically?

Claudio Grondi claudio.grondi at
Thu Nov 17 11:22:18 CET 2005

"Mikael Olofsson" <mikael at> schrieb im Newsbeitrag
news:dlhcch$gud$1 at
> bobueland at wrote:
> > I tried to put the line
> > from btools import *
> > in several places in
> > but to now avail. It does not work, IDLE does not execute it???
> IDLE definitely executes 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 After importing both sys
> and os,
> sys.modules['__main__'].__dict__['os'] = os
> Then, if I start IDLE, the module os is directly available.
> /MiO

I have put
sys.modules['__main__'].__dict__['os'] = os
at the beginning of :
#! /usr/bin/env python

import os
import os.path
import sys

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

and also here:
class ModifiedInterpreter(InteractiveInterpreter):

    def __init__(self, tkconsole):
        self.tkconsole = tkconsole

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

but it does not work ... (why ???)

What happens if you remove the line
sys.modules['__main__'].__dict__['os'] = os
from your
Will  os  be no more available or is it still there?


More information about the Python-list mailing list