New submission from David Jones:

```
for f in glob.glob('input/*/*.dat'): print f
```

outputs:

```
input/ghcnm.v3.2.2.20140611/ghcnm.tavg.v3.2.2.20140611.qca.dat
input/ghcnm.v3.2.2.20140506/ghcnm.tavg.v3.2.2.20140506.qca.dat
```

Note that these are not in the right order.  Compare with shell which always 
sorts its globs:

```
drj$ printf '%s\n' input/*/*.dat
input/ghcnm.v3.2.2.20140506/ghcnm.tavg.v3.2.2.20140506.qca.dat
input/ghcnm.v3.2.2.20140611/ghcnm.tavg.v3.2.2.20140611.qca.dat
```

I think the shell behaviour is better and we should be allowed to rely on 
glob.glob sorting its result.

Note from the documentation: "The glob module finds all the pathnames matching 
a specified pattern according to the rules used by the Unix shell". The Unix 
shell has always sorted its globs.

----------
components: Library (Lib)
messages: 220441
nosy: drj
priority: normal
severity: normal
status: open
title: glob.glob does not sort its results
versions: Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue21748>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to