[Tutor] command line

Kirby Urner urnerk@qwest.net
Sat, 30 Mar 2002 10:12:58 -0800


>
>I understand, though, that people with a windows background
>are often unfamiliar with the "command line" and want a
>nice-looking window to work with.  In addition, many windows
>users underestimate the usefulness and power of a text editor
>and may not even be familiar with the term "text editor".
>IDLE provides both of these things for that target audience.
>
>-D

There's also the fact that the term window in most Win*
systems is anemic.  Having a command line history is only
an option (doskey) and it's not very searchable.  But
that's irrelevant too, because once in the term window's
Python shell, there's no uparrow ability to grab previously
written commands or functions, nor any scroll bar, and
that about destroys its usability as an interactive
environment.  Maybe it's different in Win2k, where uparrow
history is somehow available.

Something like IDLE is the only usable way to access the
Python shell in most versions of Win* (doesn't have to
be IDLE -- e.g. PyCrust is another option, or the
PythonWin IDE from ActiveState).

What's nice in shell mode is to have textbox prompts for
function args, e.g. when I type in IDLE or some other
relatively sophisticated shell:

  >>> wpack(

I immediately get a yellow rectangle next to the function
telling me what arguments are expected and what their default
values are.  That's nice -- even a pro doesn't want to
memorize all the arg lists for every function.  I also like
the color coding of key words.

I prefer shell mode to the command line (by which I mean
starting python scripts by passing a script as an argument
to python) because I like the granular control over
the contents of a module, without having to write any
menus with raw_input prompts (a command I rarely use) or
parse sys args.  Being in shell vis-a-vis a module or
modules is more like being at the command line in an OS,
whereas scripts have a "canned" feeling -- too scripted
(not that I don't run them -- just not my preferred mode
of using Python).

I like to have a text editor open (could be Vim) wherein
I edit modules and reload them in the shell, debugging and
enhancing as I go.  The open module shows me what the
functions and classes are (or I can enter help(module)),
and if I want a new one, I stick it in.  But I'm usually
interacting with these functions from the shell, e.g.

   >>> from wmproject import *
   >>> wpack(10,abc=1)

will generate a povray file of close packed, color coded
balls starting at distance sqrt(10) from the origin and
working inward, and rotated in a particular way vis-a-vis
the xyz axes.  I'd rather run it this way than parse sys.args
in a script (I rarely use sys.args).

In *nix systems, you can use bang notation to tie a file
to the executing interpreter (#!python) while in Win* you
have to use file association, in which case you can run
a python script by just clicking on it in the Windows GUI.

Kirby