In <[EMAIL PROTECTED]>, IamIan wrote:

> Hello all,
> 
> I'm trying to use a regular expression in an FTP script to list
> certain files. When run in a standard FTP session the command:
> 
> dir ????????.??[oOdDnNmM]*
> 
> returns 48 files. When I use the following Python script it prints
> roughly 12 files (a subset of the 48), ending with 'None':
> 
> […]
> 
> Is my Python syntax off?

Your `re` syntax is off.  What you give FTP is a shell or glob pattern,
not a regular expression for the `re` module.

The `fnmatch` module has a function to translate a glob pattern to a `re`
pattern:

In [8]: fnmatch.translate('????????.??[oOdDnNmM]*')
Out[8]: '........\\...[oOdDnNmM].*$'

Ciao,
        Marc 'BlackJack' Rintsch
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to