Python 3.5 glob.glob() 2nd param (*) and how to detect files/folders beginning with "."?

Malcolm Greene python at bdurham.com
Tue Jul 26 12:52:30 EDT 2016


Hi Jussi,

You answered my questions - thank you!
Malcolm

<snipped>
> 1. The signature for glob.glob() is "glob.glob(pathname, *,
>    recursive=False)". What is the meaning of the 2nd parameter listed
>    with an asterisk?

It's not a parameter. It's special syntax to indicate that the remaining
parameters are keyword-only.

>  2. Is there a technique for using glob.glob() to recognize files and
>    folders that begin with a period, eg. ".profile"? The documentation
>    states: "If the directory contains files starting with . they won’t
>    be matched by default.". Any suggestions on what the non-default
>    approach is to match these type of files?

Glob with a pattern that starts with a dot. Glob twice if you want both
kinds. Or look into that fnmatch that is referenced from glob
documentation and said not to consider leading dots special.
</snipped>



More information about the Python-list mailing list