[issue9584] Allow curly braces in fnmatch

2010-09-27 Thread Constantin Veretennicov
Changes by Constantin Veretennicov : -- nosy: +kveretennicov ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: htt

[issue9584] Allow curly braces in fnmatch

2010-08-17 Thread Terry J. Reedy
Changes by Terry J. Reedy : -- resolution: rejected -> stage: committed/rejected -> patch review ___ Python tracker ___ ___ Python-bug

[issue9584] Allow curly braces in fnmatch

2010-08-17 Thread Fred L. Drake, Jr.
Fred L. Drake, Jr. added the comment: It's worth noting that the sh-like shells are far more widely used than the csh-like shells, so csh-like behavior may surprise more people. >From the sh-like shell perspective, the {...,...} syntax just isn't part of >the globbing handling. -- no

[issue9584] Allow curly braces in fnmatch

2010-08-17 Thread Ronald Oussoren
Ronald Oussoren added the comment: I agree with Antoine that this would be useful functionality and that matching "the" shell is futile here. A quick check on an old linux server: bash and ksh do brace expansion before expanding '*', but that csh does both at the same time. That is, in a dir

[issue9584] Allow curly braces in fnmatch

2010-08-14 Thread Éric Araujo
Éric Araujo added the comment: python-idea is read by more people. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubsc

[issue9584] Allow curly braces in fnmatch

2010-08-14 Thread Mathieu Bridon
Mathieu Bridon added the comment: Wow, I certainly didn't expect to generate so much controversy. :-/ First of all, thanks for the comments on the patch Antoine and David. > I don't get what the purpose of these two lines is. Forbid empty patterns? I copy-pasted the handling of the '[' charac

[issue9584] Allow curly braces in fnmatch

2010-08-13 Thread Tim Golden
Tim Golden added the comment: I don't see any reason to turn this down except, perhaps, for keeping something simple. Certainly I don't believe that Windows users will be confused by the fact that there are wildcards other than "*" and "?". fnmatch already implements [] and [!] which are no

[issue9584] Allow curly braces in fnmatch

2010-08-13 Thread R. David Murray
R. David Murray added the comment: Well, Windows supports * and ? globs, but not brace expansion, as far as I can tell (at least on XP, which is what I currently have access to). In fact, I don't believe I've run into brace expansion anywhere except in the unix shell, whereas as you say * and

[issue9584] Allow curly braces in fnmatch

2010-08-13 Thread Antoine Pitrou
Antoine Pitrou added the comment: > My view is that people using fnmatch/glob are expecting to get back > the same list of files that they would if they ran 'echo > ' in the shell. But it's not the case since we currently don't process braces anyway. > The major shells (sh, bash, zsh, csh) see

[issue9584] Allow curly braces in fnmatch

2010-08-13 Thread R. David Murray
R. David Murray added the comment: My view is that people using fnmatch/glob are expecting to get back the same list of files that they would if they ran 'echo ' in the shell. The major shells (sh, bash, zsh, csh) seem to be pretty consistent in this regard (though sh does less brace expansi

[issue9584] Allow curly braces in fnmatch

2010-08-13 Thread Eric Smith
Eric Smith added the comment: I'm not sure it has to be consistent with the shell to be useful, as long as the behavior is documented and we possibly add a note explaining the differences from the shell. But I agree that a discussion on python-ideas would be helpful. -- nosy: +eric.s

[issue9584] Allow curly braces in fnmatch

2010-08-13 Thread Antoine Pitrou
Antoine Pitrou added the comment: > Doing the equivalent of brace expansion would have to be done before > applying globbing, to be consistent with the shell. I don't get the "shell consistency" argument. First, there is no single definition of "the shell". Second, users of Python generally do

[issue9584] Allow curly braces in fnmatch

2010-08-13 Thread R. David Murray
R. David Murray added the comment: Ah, I had forgotten that detail, Éric. No, it doesn't seem as if implementing braces as matchers is appropriate. fnmatch is only implementing the shell file name globbing. Doing the equivalent of brace expansion would have to be done before applying globbin

[issue9584] Allow curly braces in fnmatch

2010-08-13 Thread Éric Araujo
Éric Araujo added the comment: In Bash, * and ? match only characters in existing files, but {a,b} always produces two filenames, even if the files don’t exist. Do we want to mimic this behavior in fnmatch? -- nosy: +eric.araujo ___ Python tracker

[issue9584] Allow curly braces in fnmatch

2010-08-13 Thread R. David Murray
R. David Murray added the comment: Thanks for this suggestion and patch. In general I think more tests would be good, A test for {} would clarify what you are expecting there. -- nosy: +r.david.murray stage: -> patch review versions: +Python 3.2

[issue9584] Allow curly braces in fnmatch

2010-08-13 Thread Antoine Pitrou
Antoine Pitrou added the comment: Thanks for the patch. +if j < n and pat[j] == '}': +j = j+1 I don't get what the purpose of these two lines is. Forbid empty patterns? +while i < n and pat[j] != '}': +j = j+1 You probably mean "while j

[issue9584] Allow curly braces in fnmatch

2010-08-13 Thread Mathieu Bridon
Mathieu Bridon added the comment: > The attached patch allows for shell curly braces with fnmatch.filter(). Oops, I meant that it allows for curly braces in fnmatch.translate(), which makes it available in the whole fnmatch module. -- ___ Python tr

[issue9584] Allow curly braces in fnmatch

2010-08-13 Thread Mathieu Bridon
New submission from Mathieu Bridon : The attached patch allows for shell curly braces with fnmatch.filter(). This makes the following possible: >>> import fnmatch >>> import os >>> >>> for file in os.listdir('.'): ... if fnmatch.fnmatch(file, '*.{txt,csv}'): ... print file ... file.c