Re: [Tutor] Redux: optparse

2008-12-28 Thread Kent Johnson
On Sat, Dec 27, 2008 at 2:55 PM, Matt Herzog wrote: > What I can't figure out now is how to pass a compiled regex to an optparse > option. I'm confused ias to "option" versus "arg" when using the optparse > module. In fact there seems to be no way to define what the arg should be; > only option

Re: [Tutor] Redux: optparse

2008-12-27 Thread Matt Herzog
> Do you want to use optparse, or get the command line arguments yourself? > It seems the pattern string will be the first arg, will it? Again I am confused. I assumed that optparse was the best way to pass in arguments (such as filenames) from the command line. Like so: ./script.py -x r

Re: [Tutor] Redux: optparse

2008-12-27 Thread spir
Le samedi 27 décembre 2008 à 14:55 -0500, Matt Herzog a écrit : > On Wed, Dec 24, 2008 at 01:12:55AM -, Alan Gauld wrote: > > > > "Kent Johnson" wrote > > > > >> for filename in os.listdir(directory): > > >> result = re.match(s, filename) > > >> print result > > > > > >You

[Tutor] Redux: optparse

2008-12-27 Thread Matt Herzog
On Wed, Dec 24, 2008 at 01:12:55AM -, Alan Gauld wrote: > > "Kent Johnson" wrote > > >> for filename in os.listdir(directory): > >> result = re.match(s, filename) > >> print result > > > >You never open and read the files. You are searching for the pattern > >in the filenam