newbie - How do I import automatically?

Claudio Grondi claudio.grondi at freenet.de
Wed Nov 16 14:34:28 EST 2005


<bobueland at yahoo.com> schrieb im Newsbeitrag
news:<1132154531.395649.168870 at g14g2000cwa.googlegroups.com>...
> 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???
> Bob

I have to give up here :-( .

The best solution I am able to come up with is:

    def runsource(self, source):

        if(source == ''):
           source = 'from btools import *'

        "Extend base class method: Stuff the source in the line cache first"
        filename = self.stuffsource(source)

which performs 'from btools import *' each time you hit return on the
command line without typing anything in the interpreter.

Maybe someone knowledgable in IDLE can share here a better way how to
initialize IDLE with any code valid in the interpreter itself.
Inbetween the above can maybe serve as workaround.

Claudio





More information about the Python-list mailing list