Miles <[EMAIL PROTECTED]> wrote in news:[EMAIL PROTECTED]:
> On 7/20/07, Alex Popescu <[EMAIL PROTECTED]> wrote: >> If you just want to iterate over your dict in an ordered manner than >> all you have to do is: >> >> for k in my_dict.keys().sort(): >> # rest of the code > > I think you meant sorted(my_dict.keys()), since, as you just pointed > out, the sort() method returns None. > >> If you just want to keep a list of ordered keys you can probably do >> something like: >> >> key_list = list(my_dict.keys()) >> key_list.sort() > > Creating a copy with list() is unnecessary, as keys() already returns > a copy. > > -Miles You are absolutely right about both points (it looks like answering python question very late in the evening doesn't work well for me, or at least not yet :-)). ./alex -- .w( the_mindstorm )p. -- http://mail.python.org/mailman/listinfo/python-list