Python Parameter Prompting in IDLE

4002
5
07-03-2013 09:24 AM
TroyMullins
New Contributor
While running a python script in IDLE that asks for arguments, no prompt appears that asks for parameters.  Same script in PythonWin runs fine.  A simple example:

import sys
import arcpy

x = sys.argv[1]
y = sys.argv[2]

print x y

PythonWin brings up a box to enter arguments (enter two numbers) and run script and it prints the numbers.
IDLE doesn't bring up a box or any prompt . . . . spins it's wheels for a few seconds then bombs saying no value entered.  Is there a setting I am missing when running scripts in IDLE that prompt for user input?
Same results if I use GetParameterAsText instead of sys.argv . . . .

Thanks
0 Kudos
5 Replies
LucasDanzinger
Esri Frequent Contributor
Every IDE is different, but as an example, when you click to run a script in PythonWin, there is a section to add parameters. You can just specify your parameters here. Please see the attached screenshot as an example.
0 Kudos
TroyMullins
New Contributor
Thanks Lucas . . . I know I probably wasn't clear . . . Yes, I get same thing in PythonWin as you, no problem. How would I get such a prompt to enter arguments when I run the same script in IDLE though? When run in IDLE, it processes for a few seconds, then crashes and says no values - never had a prompt like PythonWin though to enter values. Do you know how to do or configure that in IDLE?
0 Kudos
ModyBuchbinder
Esri Regular Contributor
Hi Troy

As far as I know there is no way for parameters in IDLE.
You can run it from CMD window if you like.
Since you cannot stop for debug you do not really important.
I just replace the line "x = sys.argv[1]" with "x = SomeValue" when I want to run from IDLE

Have fun
0 Kudos
fenggao1
New Contributor
Every IDE is different, but as an example, when you click to run a script in PythonWin, there is a section to add parameters. You can just specify your parameters here. Please see the attached screenshot as an example.


Hi. could u tell me how can i get PythonWin IDLE?

Thank you.

JimmyGao
0 Kudos
ModyBuchbinder
Esri Regular Contributor
Hi

there is information here: http://resources.arcgis.com/en/help/main/10.1/0021/002100000021000000.htm but the link is broken.
You can find in google.
I think PyScripter is much better, it has parameters too.

Have Fun
Mody
0 Kudos