Interactive Shell?

Josiah Carlson jcarlson at nospam.uci.edu
Sun Feb 1 23:44:04 EST 2004


> learned what I have from Lisp, I understand the >>> prompt in "Learning Python"
> and I have fun using the interactive shell, playing with strings and functions.

Welcome back.


> Which is the best was to use Python: from the interactive shell, as a scripting
> language, or as the Python.h library with C? Is the interactive shell there for
> anything beyond prototyping code?

I use the interactive shell as a calculator, to process text (in various 
ways), to run through ideas that I don't know will work or not (usually 
having to do with strange object behavior), etc.  I find it very useful 
for testing mostly.

Honestly, I've never used Python.h and embedding Python in C, so I can't 
comment on it.

What I have done quite often is to write full featured applications, 
both for the console and with a GUI.  Dropping a set of definitions 
(function, class, etc.) and calls into a .py file, then running it with 
'python script.py' is enough to get you on your way.  I've got no less 
than 100 scripts for various uses, from parsing and data compression 
(lzw-like and huffman) to image manipulation (image normalization, line 
detection, etc.), programming tools, etc.  Heck, Idle is a .py script, 
as are many thousands of other useful applications.  My personal 
favorite is PyPE (http://pype.sourceforge.net), but being the author, I 
am biased.

There are also various utilities that allow you to bundle your Python 
application/script/whatever into a binary, for those that don't want to 
install the Python runtime.

If you haven't started looking through the standard module library, you 
really should.  There are quite a few modules that will likely make 
programming with Python that much easier for you in the future.  As a 
quick suggestion, read about the sys, os, and optparse modules.  Most 
people forget to read about the first two and end up asking questions 
that get asked 3 times/week.  The first one is for some VERY useful 
per-system constants, and optparse will make your life of dealing with 
commandline arguments that much easier.

Good luck,
  - Josiah



More information about the Python-list mailing list