By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,908 Members | 2,055 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,908 IT Pros & Developers. It's quick & easy.

IDLE question

P: n/a
IDLE doesn't seem to honor PYTHONSTARTUP environment variable nor
sitecustomize.py

How do you then customize in IDLE?

(basically I want to execute the statement
from btools import *
each time I restart IDLEs Python Shell)

Nov 22 '05 #1
Share this Question
Share on Google+
18 Replies


P: n/a

<bo*******@yahoo.com> schrieb im Newsbeitrag
news:11**********************@f14g2000cwb.googlegr oups.com...
IDLE doesn't seem to honor PYTHONSTARTUP environment variable nor
sitecustomize.py

How do you then customize in IDLE?

(basically I want to execute the statement
from btools import *
each time I restart IDLEs Python Shell)

Following works for me:

C:\Python24\pythonw.exe E:\Python24\Lib\idlelib\idle.py -r
E:\Python24\sitecustomize.py

or

C:\Python24\pythonw.exe E:\Python24\Lib\idlelib\idle.py -c "import os;
from path import path"

content of my sitecustomize.py is:
"
import os
from path import path
"

and both ways of invoking IDLE have the same effect (apparently of faking
execution of not shown input line) of making the modules os and the class
path available at start of IDLE.

My question in this context:
Can the PyShell.py file in C:\Python24\Lib\idlelib directory be edited
somehow to achieve same effect?

Claudio
Nov 22 '05 #2

P: n/a

<bo*******@yahoo.com> schrieb im Newsbeitrag
news:11**********************@f14g2000cwb.googlegr oups.com...
IDLE doesn't seem to honor PYTHONSTARTUP environment variable nor
sitecustomize.py

How do you then customize in IDLE?

(basically I want to execute the statement
from btools import *
each time I restart IDLEs Python Shell)

Following works for me:

C:\Python24\pythonw.exe E:\Python24\Lib\idlelib\idle.py -r
E:\Python24\sitecustomize.py

or

C:\Python24\pythonw.exe E:\Python24\Lib\idlelib\idle.py -c "import os;
from path import path"

content of my sitecustomize.py is:
"
import os
from path import path
"

and both ways of invoking IDLE have the same effect (apparently of faking
execution of not shown input line) of making the modules os and the class
path available at start of IDLE.

My question in this context:
Can the PyShell.py file in C:\Python24\Lib\idlelib directory be edited
somehow to achieve same effect?

Claudio
Nov 22 '05 #3

P: n/a
Okey I tried what you recommended

My C:\Python24\sitecustomize.py looks like this:

# sitecustomize.py
import os
from btools import *

When I enter
C:\Python24>C:\Python24\pythonw.exe C:\Python24\Lib\idlelib\idle.py -r
C:\Python24\sitecustomize.py

in commad propmt IDLE starts up and automatically imports 'os' and all
names from my btools folder. So far so good. But when I hit Ctrl+F6 and
restart Python Shell both 'os' and names from btools are gone!

When I work with IDLE I typically start a new file (File/New Window)
and when I have written the code I hit (Ctrl+S) to Save and F5 to run.
This restarts Python Shell and my names from btools are gone. It's no
solution if I'm forced to go back to command prompt and enter the long
sequance again.

Bob

Nov 22 '05 #4

P: n/a
Okey I tried what you recommended

My C:\Python24\sitecustomize.py looks like this:

# sitecustomize.py
import os
from btools import *

When I enter
C:\Python24>C:\Python24\pythonw.exe C:\Python24\Lib\idlelib\idle.py -r
C:\Python24\sitecustomize.py

in commad propmt IDLE starts up and automatically imports 'os' and all
names from my btools folder. So far so good. But when I hit Ctrl+F6 and
restart Python Shell both 'os' and names from btools are gone!

When I work with IDLE I typically start a new file (File/New Window)
and when I have written the code I hit (Ctrl+S) to Save and F5 to run.
This restarts Python Shell and my names from btools are gone. It's no
solution if I'm forced to go back to command prompt and enter the long
sequance again.

Bob

Nov 22 '05 #5

P: n/a
now a patch fixing it I have no good feeling about, but it works:

in PyShell.py in
def restart_subprocess(self):

insert in section:
"
console.showprompt()
# restart subprocess debugger

# (-Patch)
# making additional modules available in IDLE directly after
re-start of it:
self.runsource("import os; from path import path")
# (Patch-)

if debug:
"
This will provide the modules also after restart.

Hope this will not crash elsewhere because of unexpected effects of
inserting the runsource() method at that point in the code without any other
commands which are maybe necessary to keep IDLE consistent.

So IDLE experts, HELP PLEASE !!!

Claudio

<bo*******@yahoo.com> schrieb im Newsbeitrag
news:11********************@f14g2000cwb.googlegrou ps.com...
Okey I tried what you recommended

My C:\Python24\sitecustomize.py looks like this:

# sitecustomize.py
import os
from btools import *

When I enter
C:\Python24>C:\Python24\pythonw.exe C:\Python24\Lib\idlelib\idle.py -r
C:\Python24\sitecustomize.py

in commad propmt IDLE starts up and automatically imports 'os' and all
names from my btools folder. So far so good. But when I hit Ctrl+F6 and
restart Python Shell both 'os' and names from btools are gone!

When I work with IDLE I typically start a new file (File/New Window)
and when I have written the code I hit (Ctrl+S) to Save and F5 to run.
This restarts Python Shell and my names from btools are gone. It's no
solution if I'm forced to go back to command prompt and enter the long
sequance again.

Bob

Nov 22 '05 #6

P: n/a
now a patch fixing it I have no good feeling about, but it works:

in PyShell.py in
def restart_subprocess(self):

insert in section:
"
console.showprompt()
# restart subprocess debugger

# (-Patch)
# making additional modules available in IDLE directly after
re-start of it:
self.runsource("import os; from path import path")
# (Patch-)

if debug:
"
This will provide the modules also after restart.

Hope this will not crash elsewhere because of unexpected effects of
inserting the runsource() method at that point in the code without any other
commands which are maybe necessary to keep IDLE consistent.

So IDLE experts, HELP PLEASE !!!

Claudio

<bo*******@yahoo.com> schrieb im Newsbeitrag
news:11********************@f14g2000cwb.googlegrou ps.com...
Okey I tried what you recommended

My C:\Python24\sitecustomize.py looks like this:

# sitecustomize.py
import os
from btools import *

When I enter
C:\Python24>C:\Python24\pythonw.exe C:\Python24\Lib\idlelib\idle.py -r
C:\Python24\sitecustomize.py

in commad propmt IDLE starts up and automatically imports 'os' and all
names from my btools folder. So far so good. But when I hit Ctrl+F6 and
restart Python Shell both 'os' and names from btools are gone!

When I work with IDLE I typically start a new file (File/New Window)
and when I have written the code I hit (Ctrl+S) to Save and F5 to run.
This restarts Python Shell and my names from btools are gone. It's no
solution if I'm forced to go back to command prompt and enter the long
sequance again.

Bob

Nov 22 '05 #7

P: n/a
I did as you suggested, however

after I make a new File (File/New Window) and save and then run (F5) I
get the following alert

The Python Shell is already executing a command; please waith until it
is finished

I also get the error message

Traceback (most recent call last):
File "<pyshell#1>", line 1, in -toplevel-
import os; from path import path
ImportError: No module named path


Bob

Nov 22 '05 #8

P: n/a
I did as you suggested, however

after I make a new File (File/New Window) and save and then run (F5) I
get the following alert

The Python Shell is already executing a command; please waith until it
is finished

I also get the error message

Traceback (most recent call last):
File "<pyshell#1>", line 1, in -toplevel-
import os; from path import path
ImportError: No module named path


Bob

Nov 22 '05 #9

P: n/a

<bo*******@yahoo.com> schrieb im Newsbeitrag
news:11**********************@g43g2000cwa.googlegr oups.com...
I did as you suggested, however

after I make a new File (File/New Window) and save and then run (F5) I
get the following alert

The Python Shell is already executing a command; please waith until it
is finished

I also get the error message

Traceback (most recent call last):
File "<pyshell#1>", line 1, in -toplevel-
import os; from path import path
ImportError: No module named path


Bob

Sure you have to replace "import os; from path import path"
with " from btools import *", than you avoid the error message
but not the problem you have got with the message box.
A "solution" to the problem with the message box may be as follows:

"
console.showprompt()
# restart subprocess debugger

# (-Patch)
# making additional modules available in IDLE directly after
re-start of it:
self.runsource("import os; from path import path")
time.sleep(0.1)
# (Patch-)

if debug:
"
If 0.1 doesn't work on your system, just increase the value, but this will
delay the response.
e.g. 0.001 doesn't work for me, but 0.1 does (Intel Pentium 4 running at 2.8
GHz).

Claudio
Nov 22 '05 #10

P: n/a

<bo*******@yahoo.com> schrieb im Newsbeitrag
news:11**********************@g43g2000cwa.googlegr oups.com...
I did as you suggested, however

after I make a new File (File/New Window) and save and then run (F5) I
get the following alert

The Python Shell is already executing a command; please waith until it
is finished

I also get the error message

Traceback (most recent call last):
File "<pyshell#1>", line 1, in -toplevel-
import os; from path import path
ImportError: No module named path


Bob

Sure you have to replace "import os; from path import path"
with " from btools import *", than you avoid the error message
but not the problem you have got with the message box.
A "solution" to the problem with the message box may be as follows:

"
console.showprompt()
# restart subprocess debugger

# (-Patch)
# making additional modules available in IDLE directly after
re-start of it:
self.runsource("import os; from path import path")
time.sleep(0.1)
# (Patch-)

if debug:
"
If 0.1 doesn't work on your system, just increase the value, but this will
delay the response.
e.g. 0.001 doesn't work for me, but 0.1 does (Intel Pentium 4 running at 2.8
GHz).

Claudio
Nov 22 '05 #11

P: n/a
Here a correction of the code snippet:

console.text.mark_gravity("restart", "left")
# (-Patch)
# making additional modules available in IDLE directly after
re-start of it:
self.runsource("import os; from path import path")
time.sleep(0.1)
# (Patch-)
console.showprompt()

# restart subprocess debugger

I have no slightest idea why does it make a difference.
What would make much more sense for me is to wait until
self.tkconsole.executing
is False
but this resulted in an endless loop ...

Claudio

"Claudio Grondi" <cl************@freenet.de> schrieb im Newsbeitrag
news:3u************@individual.net...

<bo*******@yahoo.com> schrieb im Newsbeitrag
news:11**********************@g43g2000cwa.googlegr oups.com...
I did as you suggested, however

after I make a new File (File/New Window) and save and then run (F5) I
get the following alert

The Python Shell is already executing a command; please waith until it
is finished

I also get the error message

Traceback (most recent call last):
File "<pyshell#1>", line 1, in -toplevel-
import os; from path import path
ImportError: No module named path
>>
Bob

Sure you have to replace "import os; from path import path"
with " from btools import *", than you avoid the error message
but not the problem you have got with the message box.
A "solution" to the problem with the message box may be as follows:

"
console.showprompt()
# restart subprocess debugger

# (-Patch)
# making additional modules available in IDLE directly after
re-start of it:
self.runsource("import os; from path import path")
time.sleep(0.1)
# (Patch-)

if debug:
"
If 0.1 doesn't work on your system, just increase the value, but this will
delay the response.
e.g. 0.001 doesn't work for me, but 0.1 does (Intel Pentium 4 running at

2.8 GHz).

Claudio

Nov 22 '05 #12

P: n/a
Here a correction of the code snippet:

console.text.mark_gravity("restart", "left")
# (-Patch)
# making additional modules available in IDLE directly after
re-start of it:
self.runsource("import os; from path import path")
time.sleep(0.1)
# (Patch-)
console.showprompt()

# restart subprocess debugger

I have no slightest idea why does it make a difference.
What would make much more sense for me is to wait until
self.tkconsole.executing
is False
but this resulted in an endless loop ...

Claudio

"Claudio Grondi" <cl************@freenet.de> schrieb im Newsbeitrag
news:3u************@individual.net...

<bo*******@yahoo.com> schrieb im Newsbeitrag
news:11**********************@g43g2000cwa.googlegr oups.com...
I did as you suggested, however

after I make a new File (File/New Window) and save and then run (F5) I
get the following alert

The Python Shell is already executing a command; please waith until it
is finished

I also get the error message

Traceback (most recent call last):
File "<pyshell#1>", line 1, in -toplevel-
import os; from path import path
ImportError: No module named path
>>
Bob

Sure you have to replace "import os; from path import path"
with " from btools import *", than you avoid the error message
but not the problem you have got with the message box.
A "solution" to the problem with the message box may be as follows:

"
console.showprompt()
# restart subprocess debugger

# (-Patch)
# making additional modules available in IDLE directly after
re-start of it:
self.runsource("import os; from path import path")
time.sleep(0.1)
# (Patch-)

if debug:
"
If 0.1 doesn't work on your system, just increase the value, but this will
delay the response.
e.g. 0.001 doesn't work for me, but 0.1 does (Intel Pentium 4 running at

2.8 GHz).

Claudio

Nov 22 '05 #13

P: n/a
This works!

Thanks Claudio

For complete happiness I would also like to know what's hapening. Is
there anywhere I can read about PyShell.py.

Bob

Nov 22 '05 #14

P: n/a
This works!

Thanks Claudio

For complete happiness I would also like to know what's hapening. Is
there anywhere I can read about PyShell.py.

Bob

Nov 22 '05 #15

P: n/a
<bo*******@yahoo.com> wrote
This works!

Thanks Claudio I am glad, that the time I put into it was not wasted.
For complete happiness I would also like to know what's hapening.
Is there anywhere I can read about PyShell.py.


Not that I would know about (except reading the source code).

Maybe this below is the right place to ask further questions (2004 there was
a discussion about IDLE):
http://mail.python.org/mailman/listinfo/tutor
but I have to admit, I haven't used this forum myself yet.

From my experience with learning Python I suppose, that it will be not very
easy to fully understand what is going on in IDLE (i.e. in PyShell.py)
because this probably requires full understanding of the Tkinter interface
and some insight into deep Python internals. Perhaps this is the reason why
noone knowledgable in this area has responded here expecting from a response
more trouble than success?

Claudio
Nov 22 '05 #16

P: n/a
<bo*******@yahoo.com> wrote
This works!

Thanks Claudio I am glad, that the time I put into it was not wasted.
For complete happiness I would also like to know what's hapening.
Is there anywhere I can read about PyShell.py.


Not that I would know about (except reading the source code).

Maybe this below is the right place to ask further questions (2004 there was
a discussion about IDLE):
http://mail.python.org/mailman/listinfo/tutor
but I have to admit, I haven't used this forum myself yet.

From my experience with learning Python I suppose, that it will be not very
easy to fully understand what is going on in IDLE (i.e. in PyShell.py)
because this probably requires full understanding of the Tkinter interface
and some insight into deep Python internals. Perhaps this is the reason why
noone knowledgable in this area has responded here expecting from a response
more trouble than success?

Claudio
Nov 22 '05 #17

P: n/a
I made bat file called startidle.bat which I put in C:\Python24
directory. This is how it looks

@echo off
start C:\Python24\pythonw.exe C:\Python24\Lib\idlelib\idle.py -r
C:\Python24\sitecustomize.py
exit

Now I put a shortcut of startidle.bat in Quick Launch. The only thing I
have to do now is to click on the shortcut icon in the Quick Launch and
I'm up and running.

Alla Tua Salute Claudio

Bob

Nov 22 '05 #18

P: n/a
I made bat file called startidle.bat which I put in C:\Python24
directory. This is how it looks

@echo off
start C:\Python24\pythonw.exe C:\Python24\Lib\idlelib\idle.py -r
C:\Python24\sitecustomize.py
exit

Now I put a shortcut of startidle.bat in Quick Launch. The only thing I
have to do now is to click on the shortcut icon in the Quick Launch and
I'm up and running.

Alla Tua Salute Claudio

Bob

Nov 22 '05 #19

This discussion thread is closed

Replies have been disabled for this discussion.