Message30303
Logged In: YES
user_id=1624709
Thanks for your answers. Although I'm pretty new at Python, but I disagree with you.
I see, it's not a bug. And folders like "[ ]" aren't very common.
But if you scan your filesystem recursively using glob, you will lose all folders named like
"[ ]":
>>def scanDir(path):
>> elements = glob.glob(directoryPath + "\\*")
>> for currentElement in elements:
>> if os.path.isfile(currentElement):
>> print currentElement
>> else:
>> scanDir(currentElement)
Even if these folders are very rare, the damage could be great. You lose files without
recognizing it.
A programmer assums that a language works correctly in all cases. So I think this should be
changed.
One easy solution is to add a second optional boolean parameter for glob, which have to be
true, if you want to use regular expressions.
But this and other similar solutions fail, if you try to use glob recursively, as the example
above shows.
A solution that would work with my example could be that glob returns the paths and puts every
"[" and "]" (and other affected charecters) in brackets, as potten recommended. On the other
hand, the result is unhandily if you don't want to use it for glob again.
So I don't no a nice solution. Maybe you have better ideas...
Thanks, Koblaid |
|
Date |
User |
Action |
Args |
2007-08-23 14:44:04 | admin | link | issue1580472 messages |
2007-08-23 14:44:04 | admin | create | |
|