[Python-ideas] Add OS-dependent automatic glob support

Chris Angelico rosuav at gmail.com
Mon Jan 5 22:33:41 CET 2015


On Tue, Jan 6, 2015 at 7:33 AM,  <random832 at fastmail.us> wrote:
> On Mon, Jan 5, 2015, at 13:45, Skip Montanaro wrote:
>> I only discovered this "shortcoming" (or "Bourne Shell dependency")
>> relatively recently. I've been using bash for so long it never even
>> occurred to me that {...} notation wasn't available in all shells.
>
> Brace expansion is technically not globbing. yen{2,3}.txt will return
> yen2.txt yen3.txt even if one or both of those files don't exist. The
> reason it works with globs is that yen{2,3}.* literally expands to
> yen2.* yen3.* which is then globbed.

Which, by the way, is the main reason I use brace expansion. Type "mv"
and then fill in a file name using tab completion, then insert or
delete something by editing it to have braces and a comma:

mv some-long-file-name-blah-blah-blah
mv some-{long-,}file-name-blah-blah-blah

Et voila! Remove one word from a tab-completed file name. There's no
way that a generic glob expansion tool can do everything that bash
does, and I doubt anyone expects it.

ChrisA


More information about the Python-ideas mailing list