Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW)
OpenStudy (anonymous):

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?

OpenStudy (anonymous):

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.

OpenStudy (anonymous):

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?

OpenStudy (anonymous):

in idle, select file | new window. write your script in the new window. when you are ready select the run | run module menu option.

OpenStudy (anonymous):

So you're both writing programs without the >>>s to begin with. And you're writing programs without the instantaneous interpreter. Right?

OpenStudy (anonymous):

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.

OpenStudy (anonymous):

Thank you! Totally clears it up. That also eliminates my annoyance with not being able to delete previous lines in the interpreter. DUH!

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
Victorya: why do you use math in this world?
32 minutes ago 10 Replies 5 Medals
Gorillaz1002: i need your opinion on this i updated it a little
2 hours ago 23 Replies 3 Medals
MrsHero: Help ss down below ;/..
2 hours ago 7 Replies 1 Medal
MrsHero: Help ss down below ;/
2 hours ago 0 Replies 0 Medals
nettym: math help please.
2 hours ago 10 Replies 3 Medals
MrsHero: Can yall rate my pic i took in Meepcity/roblox SS down bellow
2 hours ago 8 Replies 0 Medals
MrsHero: Helpp ss down bellow i suck at math thts wy im here u270c
2 hours ago 5 Replies 0 Medals
DONTPISSWITHME: What is 45^2 please help me
2 hours ago 21 Replies 1 Medal
MrsHero: help ss down below ud83dude2auff1eufe4fuff1c
2 hours ago 9 Replies 1 Medal
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!