ianaré wrote:
>
> files.sort(key=lambda x: x.lower())
> files.sort(key=lambda x: os.path.dirname(x))
This is exactly why some of us hate lambda. It encourages
long-way-around thinking.
files.sort(key=lambda x: os.path.dirname(x))
is better written as:
files.sort(key=os.path.dirn
sweet that works great!
thanks again for all the help.
--
http://mail.python.org/mailman/listinfo/python-list
ianaré wrote:
>> you did make me understand a way to sort this thing finally: sort by
> base path then by full path, which is how i came up with:
>
> files.sort(key=lambda x: x.lower())
> files.sort(key=lambda x: os.path.dirname(x))
>
> well actually i am sorting first by full name, then by base
arrrg i did it again, not enough explanation... new to asking for
programing help online.
anyway the reason is that the list can be rearanged later in the
program by another function, and i need a way to put it in order
again.. so yes it is doing some pretty funky stuff, lol.
so although your metho
ianaré wrote:
> However, i need the sorting done after the walk, due to the way the
> application works... should have specified that, sorry.
If your desired output is just a sorted list of files, there is no good
reason that you shouldn't be able sort in place. Unless your app is
doing somethin
thank you for the help, i didn't know you could sort in place like
that. definitly will come in handy.
However, i need the sorting done after the walk, due to the way the
application works... should have specified that, sorry.
TIA
--
http://mail.python.org/mailman/listinfo/python-list
Kent Johnson wrote:
> dirs.sort(key=str.lower) # note no need for lambda
However, this will raise a TypeError for unicode directory names while the
lambda continues to work.
Peter
--
http://mail.python.org/mailman/listinfo/python-list
ianaré wrote:
> 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,
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):