saving python

Started by
20 comments, last by Zahlman 17 years, 6 months ago
Don't type your programs into the first IDLE window you see. Instead, open a new window from the menu. Then you can use the 'Save' function in that window.
Advertisement
Quote:Original post by Kylotan
Don't type your programs into the first IDLE window you see. Instead, open a new window from the menu. Then you can use the 'Save' function in that window.


Be sure to save it in the "filename.py" format before you start, so the color coding is visible.
hmmm..... i did what you guys told me to do, and now the icon whenener i save is now a snake thingie, so im getting there....
however, there is still a problem. whenever i run it, this command thing flashed for like half a second then closed and thats all that happened. is there an error in the code?
the code was:
print "blabla"
Quote:Original post by Zaku
whenever i run it, this command thing flashed for like half a second then closed and thats all that happened. is there an error in the code?


That is normal behavior for a console application run from Windows. Not a Python thing it happens no matter what language the app is programmed in. For development purposes, people sometimes will put a pausing command at the end of the program that waits for a keypress before ending. In Python this could be a call to raw_input. But be warned that pausing is NOT normal program behavior so when the time comes that you want to give your programs to other people you must not do that. People generally don't want a program hanging around when it has finished doing its work.

yeah but it didnt give me the output of the program
It probably did, but then it closed to fast to see it. Put in a pause and see if the output is there. Better yet, run the application from a console (command prompt) for now. To do that just open the Windows command prompt, cd into the directory your scipt is in, then run "python myscript.py". This makes it easier to run the program with various options, and to see some output when your program crashes horribly (which is will do many times while you are starting to learn ... don't get discouraged).
Yeah it's usually best to run from the command shell or the interactive interpreter. Even with a pause at the end of your script, if an exception is thrown before that it will again quickly close before you can read the error message. You can run a script from the interactive interpreter by typing execfile('whatever.py').
Quote:Original post by Hollower
Yeah it's usually best to run from the command shell or the interactive interpreter. Even with a pause at the end of your script, if an exception is thrown before that it will again quickly close before you can read the error message. You can run a script from the interactive interpreter by typing execfile('whatever.py').


is it harder to save your program in a way that a computer challenged person could just click on the icon and run the program without the need of having python installed (instead of using the command)?

[Edited by - Zaku on October 3, 2006 3:00:38 PM]
Quote:Original post by Zaku
is it harder to save your program in a way that a computer challenged person could just click on the icon and run the program (instead of using the command)?


No, you had that part working - you simply double-click on the .py file. Trust us it DID work even if it closed too fast for you to see the output. Our advice has been for you the programmer. For other people to use a program you wrote they will simply click on the icon. If it is a console app and doesn't have any kind of menu or prompt that waits for input then it should close as soon as it reaches the end. It is also possible to write GUI (Windows) applications in Python but that is a more complex subject.
oh i see what you are saying. ill try to make it wait for output, and see if it stays open


EDIT: *GASP* it finally works! thx guys =)!

[Edited by - Zaku on October 3, 2006 4:32:00 PM]

This topic is closed to new replies.

Advertisement