[issue21748] glob.glob does not sort its results

2015-11-13 Thread Dave Jones

Dave Jones added the comment:

As suggested, doc patch attached to new issue 25615.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21748] glob.glob does not sort its results

2015-11-13 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

There is nothing special with glob(). By default the ls command outputs sorted 
list of files, but os.listdir() doesn't. Python is just lower-level language 
than Posix shell. You always can call sort() on result.

It is easy to just add sort() after calling os.listdir() in current glob() 
implementation. It shouldn't significantly affect performance. I would support 
this feature. But I'm planning to implement glob() with os.scandir(), and it is 
not so easy to support sorting in that implementation.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21748] glob.glob does not sort its results

2015-11-13 Thread David Jones

David Jones added the comment:

The original bug report did not mention ls (note serhiy.storchaka). It is a red 
herring.

I accept that the Python community doesn't care to have glob.glob sorted.
But then I think you should distance yourself from the shell in the 
documentation.

It currently says:
"The glob module finds all the pathnames matching a specified pattern according 
to the rules used by the Unix shell"

You could say something like:
"The glob module finds all the pathnames matching a specified pattern, using a 
syntax inspired by the Unix shell; unlike Unix shell the ordering is not 
guaranteed"

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21748] glob.glob does not sort its results

2015-11-12 Thread Dave Jones

Dave Jones added the comment:

>From the bash man-page: "... If one of these characters appears, then the word 
>is regarded as a pattern, and replaced with an *alphabetically sorted* list of 
>filenames matching the pattern".

I would agree that glob.glob shouldn't sort its results (the overhead may be 
substantial, and there are plenty of use-cases that don't require sorting), but 
given that the documented behaviour is at odds (implicitly via the shell's 
documentation) with the implemented behaviour I would argue that it is 
premature to close this without at least adding a note to the Python docs.

(P.S. in case my comment is received poorly, I'm not the original author of 
this ticket, and no aspersions should be cast upon drj for my possibly foolish 
views!)

--
nosy: +Dave Jones

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21748] glob.glob does not sort its results

2015-11-12 Thread Eric V. Smith

Eric V. Smith added the comment:

Assuming David means "it wouldn't be unreasonable to insert a disclaimer", I 
agree.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21748] glob.glob does not sort its results

2015-11-12 Thread R. David Murray

R. David Murray added the comment:

You mean my old English teachers were wrong when they said a positive statement 
was to be preferred to a double negative? :) :)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21748] glob.glob does not sort its results

2015-11-12 Thread R. David Murray

R. David Murray added the comment:

Technically the docs are not wrong: "matches files according to the rules of 
the shell" does not say anything about sorting (matching is separate from what 
is done with the matched filenames; the shell sorts them and inserts them in 
place, python returns an unsorted list).  It also mentions using listdir, which 
is documented as unsorted.

That said, it would be reasonable to insert a disclaimer that the returned 
results are unsorted, unlike the shell.  If you want to open an new issue with 
a proposed doc patch, that would be fine.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21748] glob.glob does not sort its results

2015-11-12 Thread Eric V. Smith

Eric V. Smith added the comment:

D'oh! I read your original comment as "it would be unreasonable to insert a 
disclaimer", and then I wondered why you'd used such a convoluted sentence and 
reversed your meaning. It's all my fault. Fortunately, I don't think Mrs. 
McKinley from 11th grade English will come after me after all these years.

Sorry about that. We're in violent agreement.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21748] glob.glob does not sort its results

2015-11-11 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue21748] glob.glob does not sort its results

2014-06-14 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Actually iglob() can sort (per directory). But I don't think this is too needed 
feature. In any case you can sort result of glob().

--
nosy: +serhiy.storchaka

___
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



[issue21748] glob.glob does not sort its results

2014-06-13 Thread David Jones

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



[issue21748] glob.glob does not sort its results

2014-06-13 Thread R. David Murray

R. David Murray added the comment:

I think there is no reason to impose the overhead of a sort unless the user 
wants it...in which case they can sort it.  I'm -1 on this change.

--
nosy: +r.david.murray

___
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



[issue21748] glob.glob does not sort its results

2014-06-13 Thread Jim Jewett

Jim Jewett added the comment:

I agree with R. David Murray, but it may be worth adding a clarification 
sentence (or an example with sorted) to the documentation.  

Changing status to Pending, in hopes that any doc changes would be quick.

--
nosy: +Jim.Jewett
resolution:  - not a bug
status: open - pending

___
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



[issue21748] glob.glob does not sort its results

2014-06-13 Thread Eric V. Smith

Eric V. Smith added the comment:

I agree that glob shouldn't sort. In addition, iglob definitely can't sort, and 
I don't think you want to have glob sort but iglob not sort.

--
nosy: +eric.smith
status: pending - open

___
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