Converting a set into list

Chris Angelico rosuav at gmail.com
Sat May 14 14:22:33 EDT 2011


On Sun, May 15, 2011 at 12:14 AM, TheSaint <nobody at nowhere.net.no> wrote:
> newset= set(myset1) & set(myset2)
> list= [newset]
>
> << [{'bla', 'alb', 'lab'}]
>
> Probably list(set) is not like [set].

list(set) creates a list out of the set. [set] creates a list with one
element, the set itself. It's not a copy of the set, it's another
reference to the same set; change one and you'll see the change in the
other.

Chris Angelico



More information about the Python-list mailing list