How to union nested Sets / A single set from nested sets?

Joel Goldstick joel.goldstick at gmail.com
Thu Jan 7 00:33:49 EST 2016


On Wed, Jan 6, 2016 at 11:59 PM, Grobu <snailcoder at retrosite.invalid> wrote:

> On 04/01/16 03:40, mviljamaa wrote:
>
>> I'm forming sets by set.adding to sets and this leads to sets such as:
>>
>> Set([ImmutableSet(['a', ImmutableSet(['a'])]), ImmutableSet(['b', 'c'])])
>>
>> Is there way union these to a single set, i.e. get
>>
>> Set(['a', 'b', 'c'])
>>
>> ?
>>
>
> There's a built-in "union" method for sets :
>
> >>> a = set( ['a', 'b'] )
> >>> b = set( ['c', 'd'] )
> >>> a.union(b)
> set(['a', 'c', 'b', 'd'])
>
> HTH
> --
> https://mail.python.org/mailman/listinfo/python-list
>

plus 1

-- 
Joel Goldstick
http://joelgoldstick.com/stats/birthdays



More information about the Python-list mailing list