Program that can find a find a file for you ?

The Regular Peter Hansen peter at
Wed Sep 29 12:51:39 CEST 2004

Peter Hansen wrote:
> Im trying to write a program that can be run from the command line.
> If I want to search for example after a file with the ending .pdf, I should 
> be able to write in the command line:
> python  name of my program / the libary to search and what kind of file it 
> is example a .pdf file
> So if my program name was and the library name was library1 and the 
> test type i wanted to find was, a .pdf file
> I should write python /library1 .pdf
> I have to use some of the code below, but im very lost, I know that I have 
> use os, but not quite sure. Does any have any ideas.....

You should investigate using the standard library module
getopt, or perhaps optparse (a newer one), as they are
designed to handle command line arguments with ease.  Doing
it yourself is probably a waste of time.

(By the way, would you consider changing your "From:"
and "Reply-To:" headers to include an initial or something?

Having two Peter Hansens around here could be confusing,
and I've been a frequent contributor so you might find
many people thinking you're me and sending you hate mail
or something, and you wouldn't know why...  If you don't
want to do that, I will. I just hope your middle name
doesn't begin with "L"...)

-Peter L Hansen (the regular)

More information about the Python-list mailing list