ISO exemplary Python scripts

Rhodri James rhodri at wildebst.demon.co.uk
Sun May 10 19:10:14 EDT 2009


On Sat, 09 May 2009 17:09:38 +0100, kj <socyl at 987jk.com.invalid> wrote:

> I know that in the python world the distinction between a script
> and a (library) module is not so clear-cut, and it is common for
> library modules to have "top-level" stuff (typically test code)
> that gets run if the module is invoked directly from the command
> line.  But this is not *really* a script as I understand it, because,
> even though it "runs" directly from the command-line, it lacks the
> typical CLI amenities, such as command-line flags, help messages,
> diagnostic messages that are aimed to the "naive user" (i.e. as
> opposed to the developer), etc.  The coding of these "CLI amenities"
> is one of aspects of these "exemplary Python scripts" I'm most
> interested in learning about.

While I don't entirely agree with your definition of a script,
for a lot of those CLI amenities "optparse" is your friend.
Possibly also your enemy if you don't want to do things its way,
but it does at least make parameter handling in a user-friendly way
easy.

-- 
Rhodri James *-* Wildebeeste Herder to the Masses



More information about the Python-list mailing list