473,395 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

running IDLE from another program?

If I want to write my code in a separate text editor (I like UltraEdit)
but then press a single button to have that code run in the IDLE
environment, is that possible? I know that you can configure UE to run
external tools, but I can't figure out how to run IDLE this way, because
when I check on its properties to find it's file path, it is just the
Python directory itself.

So not only do I not know where to find the actual file to run IDLE (if
possible), but I then don't know how to run my code in IDLE (again, if
possible). I guess I could write a script or macro that opens IDLE with
a new code window ready, copies and pastes my code from UE into this
window, then runs that code, but that seems messy, if that would even
work. And wouldn't it also prompt me to save the file before running it
in IDLE anyway?

So it comes down to this: is it possible to run code (that was created
in a separate editor) in IDLE in some kind of automated way?
Mar 31 '06 #1
13 2784
John Salerno wrote:
If I want to write my code in a separate text editor (I like UltraEdit)
but then press a single button to have that code run in the IDLE
environment, is that possible? I know that you can configure UE to run
external tools, but I can't figure out how to run IDLE this way, because
when I check on its properties to find it's file path, it is just the
Python directory itself.


You probably don't need to do that. Just run the file in python
directly. I don't know UE, but when you configure an external tool, tell
it to run python.exe and pass the current file as a command line parameter.

Kent
Mar 31 '06 #2
what i do is open idle, import the codefile i've begun to write, and
then write a function:
def r():
reload(codefile)

then when I want to run it after changes, I just call the function
manually in idle.

Mar 31 '06 #3
Kent Johnson wrote:
John Salerno wrote:
If I want to write my code in a separate text editor (I like UltraEdit)
but then press a single button to have that code run in the IDLE
environment, is that possible? I know that you can configure UE to run
external tools, but I can't figure out how to run IDLE this way, because
when I check on its properties to find it's file path, it is just the
Python directory itself.


You probably don't need to do that. Just run the file in python
directly. I don't know UE, but when you configure an external tool, tell
it to run python.exe and pass the current file as a command line parameter.

Kent


I've tried a lot of combinations for the command line to execute, but
nothing is working. What format should it be in? Should it look like this:

C:\Python24\python.exe module ?

or module.ext? With or without the path of the file?

I think some of the problem might be that I need to fix the module
search path also, but I don't know which format the UE tool needs to
execute the command.
Mar 31 '06 #4
John,

If your file has the .py or .pyc extension on it, it should just run at
the command line from its own directory, assuming your environment and
path variables are set correctly.

I use NoteTab which has a different way of doing it, but basically you
should be able to run:

c:\mydir>script.py

You don't need the python.exe on the commandline.

rick

Apr 1 '06 #5
John Salerno wrote:
Kent Johnson wrote:
You probably don't need to do that. Just run the file in python
directly. I don't know UE, but when you configure an external tool, tell
it to run python.exe and pass the current file as a command line parameter.

I've tried a lot of combinations for the command line to execute, but
nothing is working. What format should it be in? Should it look like this:

C:\Python24\python.exe module ?


C:\Python24\python.exe D:\full\path\to\myprogram.py

There is a post on the UltraEdit forum from JohnJSal, is that not you?
Whoever it is got this working...
http://www.ultraedit.com/index.php?n...ghlight=python

Kent
Apr 1 '06 #6
Kent Johnson wrote:
John Salerno wrote:
Kent Johnson wrote:
You probably don't need to do that. Just run the file in python
directly. I don't know UE, but when you configure an external tool, tell
it to run python.exe and pass the current file as a command line parameter.

I've tried a lot of combinations for the command line to execute, but
nothing is working. What format should it be in? Should it look like this:

C:\Python24\python.exe module ?


C:\Python24\python.exe D:\full\path\to\myprogram.py

There is a post on the UltraEdit forum from JohnJSal, is that not you?
Whoever it is got this working...
http://www.ultraedit.com/index.php?n...ghlight=python

Kent


Yes, that's me. :) But all that that post accomplished was getting me to
run the file itself, as if I had double-clicked on it. This isn't what I
want. I want it to run in a 'debug' type of environment like IDLE so I
can see any error messages.

I tried your suggestion and seems to half-way work. But it doesn't open
the program in a different environment (such as IDLE), it just opens the
output in a new text window in UE. Here's the output:

['qIQNlQSLi', 'eOEKiVEYj', 'aZADnMCZq', 'bZUTkLYNg', 'uCNDeHSBj',
'kOIXdKBFh', 'dXJVlGZVm', 'gZAGiLQZx', 'vCJAsACFl', 'qKWGtIDCj']
Traceback (most recent call last):
File "C:\Python24\myscripts\challenge\small_letter. py", line 15, in ?
raw_input()
EOFError: EOF when reading a line
The list is the output from the script. I don't know why the end of file
error is raised though, because it wouldn't have been raised if I ran
the file in IDLE. So something still isn't quite right.
Apr 1 '06 #7
John Salerno wrote:
Kent Johnson wrote:
John Salerno wrote:
Kent Johnson wrote:

You probably don't need to do that. Just run the file in python
directly. I don't know UE, but when you configure an external tool, tell
it to run python.exe and pass the current file as a command line parameter.
I've tried a lot of combinations for the command line to execute, but
nothing is working. What format should it be in? Should it look like this:

C:\Python24\python.exe module ?
C:\Python24\python.exe D:\full\path\to\myprogram.py

There is a post on the UltraEdit forum from JohnJSal, is that not you?
Whoever it is got this working...
http://www.ultraedit.com/index.php?n...ghlight=python

Kent

Yes, that's me. :) But all that that post accomplished was getting me to
run the file itself, as if I had double-clicked on it. This isn't what I
want. I want it to run in a 'debug' type of environment like IDLE so I
can see any error messages.


I'm not sure what you mean by a 'debug' type environment. If you mean,
you want to run the program in a debugger and step through it, then this
approach won't work. If you just mean that you want to see the output of
the program, it will work.
I tried your suggestion and seems to half-way work. But it doesn't open
the program in a different environment (such as IDLE), it just opens the
output in a new text window in UE. Here's the output:

['qIQNlQSLi', 'eOEKiVEYj', 'aZADnMCZq', 'bZUTkLYNg', 'uCNDeHSBj',
'kOIXdKBFh', 'dXJVlGZVm', 'gZAGiLQZx', 'vCJAsACFl', 'qKWGtIDCj']
Traceback (most recent call last):
File "C:\Python24\myscripts\challenge\small_letter. py", line 15, in ?
raw_input()
EOFError: EOF when reading a line
OK, your program is reading from standard input and the environment set
up by UltraEdit doesn't support this. If you are trying to run
interactive programs this approach won't work.

The list is the output from the script. I don't know why the end of file
error is raised though, because it wouldn't have been raised if I ran
the file in IDLE. So something still isn't quite right.


Because IDLE does support input.

I may have put too much interpretation on your original question because
I have my editor (TextPad) configured to run the front window in Python
and I find it a very productive way to work. But it's not IDLE and it
doesn't allow interactive input. I rarely write a program that requires
keyboard input so that's not a problem for me.

One thing that is really useful about running in an editor window is
that (in TextPad, anyway) I can double-click on an error message and go
directly to the line with the error.

Anyway, it turns out IDLE has a command-line switch that lets you pass a
file to run. Try
C:\Python24\Lib\idlelib\idle -r C:\path\to\myprog.py

Kent
Apr 1 '06 #8
Kent Johnson wrote:
I'm not sure what you mean by a 'debug' type environment. If you mean,
you want to run the program in a debugger and step through it, then this
approach won't work. If you just mean that you want to see the output of
the program, it will work.
No, just an environment like IDLE that shows errors instead of just
killing the program.
OK, your program is reading from standard input and the environment set
up by UltraEdit doesn't support this. If you are trying to run
interactive programs this approach won't work.
Oh, I see! I had the raw_input() in there so it would pause the DOS
prompt for me, but after taking out that line, then it works how I want
it to.
One thing that is really useful about running in an editor window is
that (in TextPad, anyway) I can double-click on an error message and go
directly to the line with the error.
Interesting. The way I have it now, it shows errors the way I want to,
but it shows them just in a text file, nothing special, and I don't seem
to be able to double-click them. Is this just a feature of TextPad, or
did you have to set it up so you can double-click the errors?
Anyway, it turns out IDLE has a command-line switch that lets you pass a
file to run. Try
C:\Python24\Lib\idlelib\idle -r C:\path\to\myprog.py


I tried this but it said it couldn't find idle.pyw (even though it is
there).
Apr 1 '06 #9
John Salerno wrote:
Kent Johnson wrote:
One thing that is really useful about running in an editor window is
that (in TextPad, anyway) I can double-click on an error message and go
directly to the line with the error.

Interesting. The way I have it now, it shows errors the way I want to,
but it shows them just in a text file, nothing special, and I don't seem
to be able to double-click them. Is this just a feature of TextPad, or
did you have to set it up so you can double-click the errors?


mmm, both. TextPad lets me set a regular expression to interpret errors
as file/line. When that is set correctly the double-clicking works.
Try
C:\Python24\Lib\idlelib\idle -r C:\path\to\myprog.py

I tried this but it said it couldn't find idle.pyw (even though it is
there).


The working directory must be wrong. Try calling Python directly with
full paths:

C:\Python24\pythonw C:\Python24\Lib\idlelib\idle.pyw -r C:\path\to\myprog.py

Kent
Apr 1 '06 #10
Kent Johnson wrote:
The working directory must be wrong. Try calling Python directly with
full paths:

C:\Python24\pythonw C:\Python24\Lib\idlelib\idle.pyw -r C:\path\to\myprog.py


Perfect! Thank you so much!

I put this line in the command line field, and I left "working
directory" empty because I'm not sure what goes there. Should it be the
main python directory, or the directory of the file being run? Either
way, it seems to work without a working directory.

Thanks again!
Apr 1 '06 #11
John Salerno wrote:
Kent Johnson wrote:
The working directory must be wrong. Try calling Python directly with
full paths:

C:\Python24\pythonw C:\Python24\Lib\idlelib\idle.pyw -r C:\path\to\myprog.py

Perfect! Thank you so much!

I put this line in the command line field, and I left "working
directory" empty because I'm not sure what goes there. Should it be the
main python directory, or the directory of the file being run? Either
way, it seems to work without a working directory.


Great! I would set the working directory to the dir containing your
program. That way if you have multiple modules in the program you will
be able to import them without any trouble.

Kent
Apr 2 '06 #12
Kent Johnson wrote:
John Salerno wrote:
Kent Johnson wrote:
The working directory must be wrong. Try calling Python directly with
full paths:

C:\Python24\pythonw C:\Python24\Lib\idlelib\idle.pyw -r C:\path\to\myprog.py


Perfect! Thank you so much!

I put this line in the command line field, and I left "working
directory" empty because I'm not sure what goes there. Should it be the
main python directory, or the directory of the file being run? Either
way, it seems to work without a working directory.


Great! I would set the working directory to the dir containing your
program. That way if you have multiple modules in the program you will
be able to import them without any trouble.

Kent


Ok, thanks again! I love how this works now! :)
Apr 2 '06 #13
> So it comes down to this: is it possible to run code (that
was created in a separate editor) in IDLE in some kind of
automated way?


Using the Zeus for Windows IDE this should be possible. Zeus has
many options when it comes to running tools and compilers:

http://www.zeusedit.com/forum/viewtopic.php?t=32

It will also capture the tool output and allowing you to click
on the errors in the output and have the file load at the correct
line number.

Jussi Jumppanen
Author: Zeus for Windows
Note: Zeus is shareware (45 day trial).

Apr 5 '06 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ian McConnell | last post by:
What's the pythonic way of sending out a set of requests in parallel? My program throws an image at the server and then waits for the result. I'm currently using this bit of socket code to send...
15
by: Aubrey Hutchison | last post by:
### this will test if your version of IDLE on windows is a MATURE program design ### print "Hello world, If Python IDLE is a mature program design it will output this" Save this simple...
1
by: Scott | last post by:
Hey everyone! I've been working with python for quite a while and have been able to fix all my problems by searching... except for this one! I have a python script that runs *BEAUTIFULLY* when...
2
by: Otto T Hyvarinen | last post by:
We have this big Python program, developed by another institute, that uses C extensions a lot. One of those C methods does the segmentation fault when run from the command line, but _not_ when run...
17
by: los | last post by:
Hi, I'm trying to create a program similar to that of Google's desktop that will crawl through the hard drive and index files. I have written the program and as of now I just put the thread to...
11
by: a.serrano | last post by:
Hello, the following program prompts the user for a word and tests to see if it is the same as another one. If the user types "españa" (note that the word contains an 'ñ'), the program should...
4
by: tony.ha | last post by:
Hello, I have open a Python program in the IDLE, but when I select the "run module" under "run" menu, it does not allow me to pass an argument to my Python program! How do you pass an argument...
5
by: Russ P. | last post by:
I've been programming in python for a few years using XEmacs on Solaris and Linux. I've been thinking about trying IDLE for a long time, but either it wasn't available on my system or I...
2
by: W. eWatson | last post by:
I had just finished working with IDLE, and tried to double-click on a py file. It produced an OK dialog with the path to the file and the msg "access denied." All my py files act that way. I...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.