[Tutor] how to edit program files in Python?

Walter Prins wprins at gmail.com
Thu Dec 19 23:45:39 CET 2013


Hi,

On 19 December 2013 19:33, Laurie Stephan
<curriculumspecialist at yahoo.com> wrote:
> My son and I just opened "Python for Kids" and we're working our way through
> the lessons.  Sometimes he mistypes the lines and hits return and discovers
> after that that he made a mistake in the line.  But, when we try to correct
> the line, we are not able to.  We just get that loud beepy sound telling us
> it's not possible.
>
> So... is there any way to go back up to the previous line and correct the
> syntax?  As it is now we are starting the entire file over.  It's really
> cumbersome.  Is it supposed to be this way?

I'm not familiar with this book so my comments are not directed at it
and you've not mentioned exactly how you're running Python or on what
OS which makes it difficult to give you specific solutions guaranteed
to solve your problems.  But, in short, there's several ways to run
Python code, and by what you're describing it sounds like you're
working with the Python interpreter directly.  That's fine for
experimenting and testing language constructs interactively but is not
the way you'd write bigger programs.  For that you use some sort of
text editor and/or development environment.  Python comes with a
simple development environment called "IDLE".  When run this by
default also provides an interactive Python interpreter window to
experiment with.  It also has the ability to create/open Python
program files and then run them in the Python interpreter. (Click
"File"->"New", then type some Python code, save it under a suitable
filename with a .py extension, then press F5 to run it.  Then go back
to editing it and press F5 again etc.)   You should be able to find it
in your program files menu (assuming Windows) pretty easily.

Walter


More information about the Tutor mailing list