Message258257
I don't know that passing '' as a pattern to glob() makes much sense, but it is useful when passed to match(). Doing so allows me to build a filter that can easily and naturally be disabled. For example, the following allows me to get all the items in a directory that both match a select pattern and do not match a reject pattern:
def ls(dir, select='*', reject='.*'):
return (p for p in dir.glob(select) if not p.match(reject))
By default this function does not return hidden files or directories. It would seem like this restriction could be removed by passing reject='', but that generates an exception. Working around the exception makes the code noticeably more complicated.
Perhaps the question should really be 'what is the benefit of raising an exception when an empty glob string is encountered?'. I cannot think of any. |
|
Date |
User |
Action |
Args |
2016-01-15 00:42:36 | jitterman | set | recipients:
+ jitterman, gvanrossum, pitrou |
2016-01-15 00:42:36 | jitterman | set | messageid: <1452818556.39.0.786674399512.issue26113@psf.upfronthosting.co.za> |
2016-01-15 00:42:36 | jitterman | link | issue26113 messages |
2016-01-15 00:42:36 | jitterman | create | |
|