How do you program in Python?

Terry Hancock hancock at anansispaceworks.com
Mon Jul 4 06:13:54 EDT 2005


On Sunday 03 July 2005 11:35 am, anthonyberet wrote:
> What I would really like is something like an old-style BASIC 
> interpreter, in which I could list, modify and test-run sections of 
> code, to see the effects of tweaks, without having to save it each time, 
> or re-typing it over and over (I haven't even worked out how to cut and 
> paste effectively in the IDLE environment).

How old style? Basic has changed a lot over the years. ;-)

But seriously, I think I know what you mean.   I'm going to suggest that
you try going very "low tech" with this and don't use an IDE at all.  I'm
sure you have some form of window environment (X, Windows, or Mac)
and can open a terminal and an editor of your choice on screen (even if
it's "Notepad").

Start the Python interpreter up in the terminal by just typing "python".
In the interpreter you can try simple one or two liners.  You can even
define a short function and try it out.

But you'll get annoyed by having to "up-arrow" and retrieve lines one-
by-one to repeat the function after you've made a mistake, so that'll
get old for anything more than 5 lines long.

So, use your editor.   Type up a short program that you want to test
in the editor, then copy and paste it into the Python interpreter.  This
way, when you (inevitably) find mistakes, you can just tweak them in
the editor and then paste them again.

You can, of course, paste statements from the interpreter back into
your editor, but you'll have to avoid the ">>>" prompts (or delete them),
so it's usually better to write in the editor and paste into the interpreter.

And when you're done, you can just save the result to file so you
can get it back later.

My point is, you don't have to use a fancy all-in-one application to
do the job, nor must you run your programs from within your editor.
It's not so hard to just use tools you already understand.

Personally, I did things like this for years, and still do from time to time.
I've hardly ever used an IDE, and I'm still not totally convinced they
are worth the effort involved in learning them.  I used to hop from computer
to computer a lot, and if I tried to learn my way around separate IDEs
on Macs, Windows, DOS, Solaris, and Debian Linux, I would've spent
a lot of time twiddling with the tools instead of just writing code.

Lately, I've settled into using Vim, which is nice editor (especially if you
once wrote  a several thousand line program in Vi with nothing but a
fold-up quick reference for a manual ;-) ).  There may well be friendlier
ones, but I know this one fairly well, and it has a pretty large community
of developers who are constantly tweaking it to make it a better editor
for programming.  I only just recently started seriously customizing it
to work well with Python, though.

You can always go shopping for an IDE to buy into heavily *after*
you've learned the language.  Meanwhile, don't let trifles get in the
way -- just use your window system as your IDE.  That way, you
can pick the editor to suit you.  And the Python interpreter is great,
it will give you no trouble and quick answers.

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com




More information about the Python-list mailing list