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
> 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
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
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