HELP?
Philip Swartzleonard
starx at pacbell.net
Sun Feb 3 14:47:22 EST 2002
Chris Gonnerman || Sun 03 Feb 2002 06:46:08a:
> ----- Original Message -----
> From: "Callum Golding" <Rave_Dj at btopenworld.com>
>
>
>> I'm sorry to bother you, but i was wondering if you could give me a
>> little advice. I've recently downloaded Python 2.2. Ive read a
>> begginers guide to programming and tried creating a small program, I
>> used the input function. Now as soon as I open the program it goes
>> into dos and asks me the question, and when i type in an anwser, dos
>> shuts down. Now its really starting to bug me. If you could give me
>> some advice I would be real grateful. The program I wrote is below; -
>
> Fairly common problem. You neglected to state your OS but I can easily
> assume
> Windows; note that many of us use other OS's, so you should always
> state that.
>
> You are running the script from Explorer, by double-clicking? In that
> mode, a console application (like python.exe) will open a "dos window"
> (actually a Windows Console) and run in it. When the program
> terminates, the window closes (as you have noticed).
>
> Two solutions: First, run your script from the DOS prompt. Do Start,
> Run, "command", ENTER; or find MS-DOS Prompt under Start, Programs. If
> you are running NT, 2000, or XP, you can change "command" to "cmd"
> (don't type the quotes in any case, they are there to tell you that the
> quoted material is to be typed in). Once in the DOS window, change
> directories to the folder your script is in, and type
>
> python myscript.py
>
> If you get a "Bad Command or Filename" message, you need your Python
> directory
> in your DOS PATH variable. How to do this varies between 95/98 and
> NT/2000/XP,
> so you should tell us what you are using.
>
> You could type:
>
> c:\python22\python myscript.py
>
> if you installed Python 2.2 in the standard place, and that would work.
>
> Second solution: Add
>
> raw_input()
>
> as the last line of your script. Then, you will have to press ENTER to
> end the script.
>
> Learn to work at the command prompt. It's a dying art.
Third solution (more advanced):
create a pystart.bat (or similar) in your python directory, containing
'''
c:\path\to\this\version\of\python.exe %1 %2 %3 %4 %5 %6 %7 %8 %9
pause
'''
and change the command for the default action (open) for python files from
the type-manger (from some explorer window: view | folder optoins, tab
'file types') to, well, i have 'C:\programs\python22\pystart.bat "%1" %*'
This gives you a global pause for .py files--- if you generally want to
read output from console-based scripts for windows, it may be a nicer
solution. (plus you can turn off the pause, globally, by throwing a 'rem'
infront of it :)
Just have to be different :}
--
Philip Sw "Starweaver" [rasx] :: www.rubydragon.com
More information about the Python-list
mailing list