[Python-ideas] Add OS-dependent automatic glob support
Skip Montanaro
skip.montanaro at gmail.com
Mon Jan 5 19:45:38 CET 2015
On Mon, Jan 5, 2015 at 12:09 PM, Stephen J. Turnbull <
turnbull at sk.tsukuba.ac.jp> wrote:
> Which is normally "nothing" on POSIX, since the shell does it for
> you. Or, if you're talking about what the shell does for you, while I
> suppose there is a basic globbing defined by POSIX, but bash and zsh
> go well beyond that, and they behave somewhat differently in corner
> cases IIRC.
>
Indeed. I only have 2.7.2 available here at work. Here's what bash tells me
on a Linux box:
% ls yen{2,3}.*
yen2.out yen2.png yen2.trade yen3.out yen3.png yen3.trade
% ls yen[23].*
yen2.out yen2.png yen2.trade yen3.out yen3.png yen3.trade
Here's what /bin/sh tells me on a Solaris 10 box:
$ ls yen{2,3}.*
yen{2,3}.*: No such file or directory
$ ls yen[23].*
yen2.out yen2.png yen2.trade yen3.out yen3.png yen3.trade
Here's what the glob module tells me:
% python
Python 2.7.2 (default, Nov 14 2012, 05:07:35)
[GCC 4.4.6 [TWW]] on linux3
Type "help", "copyright", "credits" or "license" for more information.
>>> import glob
>>> glob.glob("yen{2,3}.*")
[]
>>> glob.glob("yen[23].*")
['yen3.trade', 'yen2.out', 'yen2.trade', 'yen3.out', 'yen3.png', 'yen2.png']
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.
Skip
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150105/b3812284/attachment-0001.html>
More information about the Python-ideas
mailing list