How to union nested Sets / A single set from nested sets?
Steven D'Aprano
steve at pearwood.info
Thu Jan 7 03:37:56 EST 2016
On Thu, 7 Jan 2016 01:45 am, Oscar Benjamin wrote:
> On 4 January 2016 at 02:40, mviljamaa <mviljamaa at kapsi.fi> 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'])
>
> Where are you getting Set and ImmutableSet from? Is that sympy or
> something?
Set and ImmutableSet were the original versions from Python 2.3 before the
builtins. They're still available up to Python 2.7 (gone in 3):
py> import sets
py> sets.Set
<class 'sets.Set'>
but that's just for backwards compatibility, you should use the built-in
versions if you can.
--
Steven
More information about the Python-list
mailing list