Alex Kleider wrote:

> On 2014-04-08 14:34, Peter Otten wrote:
> 
>> That's a change in Python 3 where dict.keys() no longer creates a list,
>> but
>> instead creates a view on the underlying dict data thus saving time and
>> space. In the rare case where you actually need a list you can
>> explicitly
>> create one with
>> 
>> ips = list(ipDic)

> Thanks, Peter, for this clarification.  I want to present the list
> sorted so probably this is the rare case of which you spoke where I
> would need to use l = list(myDict) rather than the view.

You can create and sort the list in a single step:

l = sorted(myDict)

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to