dict.has_key(x) versus 'x in dict'

Paul McGuire ptmcg at austin.rr._bogus_.com
Wed Dec 6 12:03:43 EST 2006


"Peter Otten" <__peter__ at web.de> wrote in message 
news:el6sfu$ord$02$1 at news.t-online.com...
> Andy Dingley wrote:
>
>>>     sorted(setBugsChanged)
>
>> Out of interest, whats the Pythonic way to simply cast (sic) the set to
>> a list, assuming I don't need it sorted?  The list comprehension?
>
> list(setBugsChanged)
>
> Peter

Note that this is not really a "cast" in the C sense of the word. 
list(setBugsChanged) constructs and returns a new list containing the 
elements of setBugsChanges, and leaves setBugsChanged unchanged.

-- Paul 





More information about the Python-list mailing list