Idlestartup is analogous to pythonstartup variable, but for IDLE, instead of command line.
But it seems not to work properly. I’m using python 2.6.5 on Windows.
I have the following script assigned to it:
from pprint import pprint
import sys
newPath = 'C:\\Python26\test')
sys.path.append(newPath)
print "initial config loaded"
Both variables Idlestartup and pythonstartup are assigned to the same file (script above).
When running IDLE, pprint and sys are NOT available, the final message is NOT printed, but newPath was added to sys.path.
Running the command line, pprint and sys are available, the final message is printed and newPath was added to sys.path.
Is it a bug? Am I doing something wrong?
Thanks
sys.stdoutmay not be in its final state at the timeidlestartup‘s getting loaded – so it’s quite possible that aprintto it tries to go to the “original” standard-output, and then immediately the standard output is redirected to idle’s command window and so the effects of theprintare never seen. In other words, no bugs, I think — it’s just not obvious howidlestartupmay be guaranteed to send an important message to the user, if delivery of that message must be guaranteed (a message such as your example is no big deal, but if you did have important ones I’d look intoTkways of delivering them in a guaranteed way).Edit: as for making sure that certain names are added to the main namespace, the latter’s named
__main__(both with and without idle), so adding to your code a few statements such as&c should work.