Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > ISO exemplary Python scripts

Reply
Thread Tools

ISO exemplary Python scripts

 
 
kj
Guest
Posts: n/a
 
      05-09-2009


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,
etc.

Can someone point me to good examples of Python scripts?

TIA!

kynnjo

--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
 
Reply With Quote
 
 
 
 
kj
Guest
Posts: n/a
 
      05-09-2009
In <(E-Mail Removed)> Tim Roberts <(E-Mail Removed)> writes:

>kj <(E-Mail Removed)> 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,
>>etc.
>>
>>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...

kynn

--
NOTE: In my address everything before the first period is backwards;
and the last period, and everything after it, should be discarded.
 
Reply With Quote
 
 
 
 
Rhodri James
Guest
Posts: n/a
 
      05-10-2009
On Sat, 09 May 2009 17:09:38 +0100, kj <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Python system with exemplary organization/coding style TomF Python 3 05-16-2009 08:57 PM
Suggestions for exemplary c99 code cs C Programming 4 09-04-2007 05:44 AM
Free tips and tricks for Scripts,HP Open View products, ITIL, ISO 27001, ISO 2000 etc.. ashlyak@gmail.com Computer Support 2 08-08-2007 01:05 AM



Advertisments