Re: newbie - How do I import automatically?



<bobueland@xxxxxxxxx> schrieb im Newsbeitrag
news:<1132154531.395649.168870@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>...
> 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


.



Relevant Pages

  • Re: IDLE question
    ... So IDLE experts, HELP PLEASE!!! ... > names from my btools folder. ... > restart Python Shell both 'os' and names from btools are gone! ... > and when I have written the code I hit to Save and F5 to run. ...
    (comp.lang.python)
  • Re: newbie - How do I import automatically?
    ... from btools import * in several places in PyShell.py but to now avail. ... IDLE does not execute it??? ... HTH ...
    (comp.lang.python)
  • Re: newbie - How do I import automatically?
    ... >> from btools import * ... IDLE does not execute it??? ... > IDLE definitely executes PyShell.py upon startup, ... After importing both sys ...
    (comp.lang.python)
  • Re: newbie - How do I import automatically?
    ... from btools import * ... IDLE does not execute it??? ... Prev by Date: ...
    (comp.lang.python)
  • Re: IDLE confusion
    ... This isn't really an IDLE issue, it's a Python feature which needs to ... In Python, once you've imported a module once, importing it again is ... In the IDLE interpreter you can do this from the Shell ...
    (comp.lang.python)