shutil ignore fails on passing a tuple?

Dave Angel d at
Thu Jul 19 21:20:35 CEST 2012

On 07/19/2012 12:43 PM, Alex van der Spek wrote:
> This beats me:
> ++++++++++++++++++++
>>>> ipatterns
> ('*.txt', '*.hdf', '*.pdf', '*.png')
>>>> igf = shutil.ignore_patterns(ipatterns)
>>>> ignorethis = igf(ddftopdir,os.listdir(ddftopdir))
> <SNIP>
> Why does it fail on passing in a tuple of ignore strings? I thought
> the , (comma) is pretty much the tuple constructor (if that is the
> right word).

ignore_patterns() is not looking for a tuple, it's looking for one or
more strings, as separate arguments.  If you already have the tuple, you
can expand it by using the asterisk, as Prasad ha pointed out.

igf = shutil.ignore_patterns(*ipatterns)



More information about the Python-list mailing list