arogozhnikov / python3_with_pleasure

A short guide on features of Python 3 with examples
3.63k stars 199 forks source link

Globbing with glob vs. pathlib #16

Open gpoore opened 6 years ago

gpoore commented 6 years ago

It might be worth mentioning that glob.glob and pathlib.Path.glob work slightly differently. glob.glob treats dotfiles specially, while pathlib.Path.glob uses ** only to match directories, not files. It's easy to use pathlib.Path.glob without reading the docs closely enough to realize the differences from glob.glob and bash globstar behavior, and thus construct a pattern that doesn't match what you want.

arogozhnikov commented 6 years ago

Thanks, I didn't know this, so will add a remark.

Edit: added a remark, I think some examples would help