newbie - How do I import automatically?
mikael at isy.liu.se
Thu Nov 17 11:29:21 CET 2005
bobueland at yahoo.com wrote:
>> I tried to do it on my computer (win XP). I put an extra line in
>> # test
>> sys.modules['__main__'].__dict__['os'] = os
>> Then when I start idle I get
>> IDLE 1.1.1
>> ['__builtins__', '__doc__', '__name__']
>> So I don't see 'os'
>> Do you see 'os' on your computer. If yes, what could be the difference?
> Yes, I do. [snip details]
I have to step back a bit. IDLE seems to work differently depending on
how it is started. My comments above hold when I start IDLE by
right-clicking on a python-file and choosing "Edit with IDLE".
If I instead start IDLE itself (from the windows start-menu) I get the
same behaviour as you do, namely no os around. Another difference, which
I've noted before is that shell restart is only available when IDLE has
been started this way.
All this seems to be handled in PyShell.py, but I do not have the time
to trace that in any detail.
More information about the Python-list