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

Is there a way to repair an error in a program without rewriting the entire program?

OpenStudy (chris):

OpenStudy (julie):

hey, you may be confusing the interactive interpreter (write successive commands in a prompt) with running a python text file. the command line style python interpreter is great for testing out language constructs quickly. however, once you move on to more complex programs you'll often want to create a text file that holds your python commands. the convention in python is to create a text file with the extension ".py", e.g. "prime.py" that holds the same commands you type into your interpreter. from a command line, you can then run the program with "python <filename>". That way if there are errors, you only have to change the line in your text file that caused the error - not type the whole thing again. take a look at this if you have more questions: http://docs.python.org/faq/windows.html#how-do-i-run-a-python-program-under-windows

OpenStudy (chris):

what julie said

OpenStudy (chris):

if you're on unix, then you can do > python ps1.py

OpenStudy (anonymous):

In addition, on unix, you can add a "shebang" line like this to the beginning of your program: #! /usr/bin/python Then you can make your program executable with "chmod +x ps1.py", and then execute it directly with ./ps1.py. This method is used by most system maintenance scripts. On Windows you can make an association with the .py file extension to make Python open all such files. Windows would ignore the shebang line, resulting in one file that might work on Unix/Linux, Windows, and OS X.

OpenStudy (anonymous):

Thanks Julie and others, That was exactly the confusion I had and your help solves the problem.

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
Breathless: womp
31 seconds ago 0 Replies 0 Medals
Breathless: yo who wanna match pfp?
2 minutes ago 11 Replies 1 Medal
Ylynnaa: This was long time ago lmk if u fw itud83dude1d
3 hours ago 17 Replies 2 Medals
abound: Wow question cove really fell off
5 hours ago 6 Replies 1 Medal
ayden09: chat i love black pink hehe i like jones to
5 hours ago 20 Replies 2 Medals
kamani7676: help
1 day ago 5 Replies 1 Medal
kamani7676: Help
1 day ago 76 Replies 2 Medals
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!