So I write a program. Great! It works in IDLE. But when I run it, I get syntax errors because of the automatic intro and those >>> prompts. I manually delete them, but that can't really be the way it's supposed to go. How do you go from IDLE to running a .py file in command prompt? I've read everything assigned in the first three lectures, plus some extra stuff, watched the first 3 lectures & I'm clueless. Can someone help a newbie out?
what version of python are you using? when writing your program in 2.7.x , go to the file tab and click on new window. write your program in this window and save it with a .py extension. run your program using f5 and if you still get errors, your doing something wrong. also, code should run correctly directly from the shell.
Ah, F5 is helpful, thanks! I'm using 2.7.2. I write it in the shell with the live interpreter. Then I save the file as a .py, close it, open it up to "edit wit IDLE", then delete all the >>>s, then I run it successfully. If I would initially write it in the new window, the interpreter doesn't run. Do you mean cut & paste into the new window? That still brings in all the >>>s which have to be deleted. It just seems moronic that such a high-level language would make you manually go back & delete all the stinking >>>s. There isn't a process I'm missing?
in idle, select file | new window. write your script in the new window. when you are ready select the run | run module menu option.
So you're both writing programs without the >>>s to begin with. And you're writing programs without the instantaneous interpreter. Right?
yep, i use the Idle shell a lot to try out pieces of code to see how/if it works while i am writing the scripts in the editing window.
Thank you! Totally clears it up. That also eliminates my annoyance with not being able to delete previous lines in the interpreter. DUH!
Join our real-time social learning platform and learn together with your friends!