Hey all,

if i use a os.walk() to append files to a list like so...

files = []
root = self.path.GetValue() # wx.TextCtrl input
filter = self.fileType.GetValue().lower()  # wx.TextCtrl input
not_type = self.not_type.GetValue()  # wx.CheckBox input

for base, dirs, walk_files in os.walk(root):
                    main.Update()
                    # i only need the part of the filename after the
user selected path:
                    base = base.replace(root,"")

                    for entry in walk_files:
                        entry = os.path.join(base,entry)
                        if filter != "":
                            if filter in entry.lower() and not
not_type:
                                files.append(entry)
                            if filter not in entry.lower() and
not_type:
                                files.append(entry)
                        else:
                            files.append(entry)

... will it sort properly on mac and *nix? if not, is there a tried an
true sorting method someone could graciously let me know of?
oh by sort properly i mean:
file1.ext
file2.ext
file3.ext
file4.ext
zzfile.ext
folder1\file1.ext
folder1\file2.ext
folder1\file3.ext
folder2\file1.ext
folder2\file2.ext
folder2\file3.ext


something tells me it's probably better to do my own sorting, just in
case, so i tried:

files.sort(key=lambda x: x.lower())

but that didn't work, made them out of order.

TIA

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to