Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #101320

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

From Joel Goldstick <joel.goldstick@gmail.com>
Newsgroups comp.lang.python
Subject Re: How to union nested Sets / A single set from nested sets?
Date 2016-01-07 00:33 -0500
Message-ID <mailman.38.1452144831.2305.python-list@python.org> (permalink)
References <mailman.19.1452086285.2305.python-list@python.org> <n6kr5v$amj$1@dont-email.me>

Show all headers | View raw


On Wed, Jan 6, 2016 at 11:59 PM, Grobu <snailcoder@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

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

How to union nested Sets / A single set from nested sets? mviljamaa <mviljamaa@kapsi.fi> - 2016-01-04 04:40 +0200
  Re: How to union nested Sets / A single set from nested sets? Rustom Mody <rustompmody@gmail.com> - 2016-01-06 08:19 -0800
  Re: How to union nested Sets / A single set from nested sets? Grobu <snailcoder@retrosite.invalid> - 2016-01-07 05:59 +0100
    Re: How to union nested Sets / A single set from nested sets? Joel Goldstick <joel.goldstick@gmail.com> - 2016-01-07 00:33 -0500

csiph-web