ISO exemplary Python scripts
socyl at 987jk.com.invalid
Sat May 9 12:09:38 EDT 2009
In <802a051qoqmpnih0j2su9hhriqumagu326 at 4ax.com> Tim Roberts <timr at probo.com> writes:
>kj <socyl at 987jk.com.invalid> wrote:
>>I'm learning python, for the umpteenth time. This time I decided
>>to start out by writing Python scripts for everyday tasks. Most
>>of these scripts are meant to be used only once or twice, but a
>>few of them have become useful enough that I'd like to make them
>>a little bit more solid...
>>I'd like to learn from well-written Python scripts, with well-structured
>>options parsing, good error and help messages, clear organization,
>>Can someone point me to good examples of Python scripts?
>The standard library that was installed with your interpreter is one of the
>best repositories. It contains hundreds of working, well-tested scripts,
>most of which have the ability to run by themselves.
Thanks, but the last bit of your post ("...most of which have the
ability to run by themselves") makes me wonder whether we mean the
same thing when we talk of "scripts." Can you give me an example
of a script that *does not* have the ability to run by itself?
When I use the word "script" I mean, *by definition*, a piece of
code that has the ability to run by itself.
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.
Anyway, thanks, I'll poke around in the standard library...
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
More information about the Python-list