JitterMan added the comment:
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.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue26113>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com