This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jitterman
Recipients gvanrossum, jitterman, pitrou
Date 2016-01-15.00:42:36
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1452818556.39.0.786674399512.issue26113@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2016-01-15 00:42:36jittermansetrecipients: + jitterman, gvanrossum, pitrou
2016-01-15 00:42:36jittermansetmessageid: <1452818556.39.0.786674399512.issue26113@psf.upfronthosting.co.za>
2016-01-15 00:42:36jittermanlinkissue26113 messages
2016-01-15 00:42:36jittermancreate