Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Joel Goldstick Newsgroups: comp.lang.python Subject: Re: How to union nested Sets / A single set from nested sets? Date: Thu, 7 Jan 2016 00:33:49 -0500 Lines: 32 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de K9xlVwWh1WOJRWSdNXjcaA4ZwHGrbViC4hhOhmipfelA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'cc:addr:python-list': 0.09; 'subject:How': 0.09; 'subject:set': 0.09; 'jan': 0.11; 'wed,': 0.15; '>>>': 0.15; "'b',": 0.16; "'c',": 0.16; '11:59': 0.16; '2016': 0.16; "['a',": 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'set,': 0.16; 'wrote:': 0.16; '>>>': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'forming': 0.22; 'sets': 0.23; 'header:In-Reply-To:1': 0.24; 'message- id:@mail.gmail.com': 0.27; "i'm": 0.30; 'url:mailman': 0.30; 'url:python': 0.33; 'url:listinfo': 0.34; 'received:google.com': 0.35; 'i.e.': 0.35; 'skip:i 20': 0.36; 'there': 0.36; 'url:org': 0.36; 'received:209.85': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'skip:& 10': 0.37; 'method': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'subject:from': 0.39; 'url:mail': 0.40; 'subject: / ': 0.63; 'union': 0.67; 'as:': 0.79; 'subject:Sets': 0.84; 'to:none': 0.91; 'joel': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=Jv8/LtfMHdJ8H/QQZeTphTZr4hZHsb90rLhSOcFmFm0=; b=Ubxvpu2BH6THGHddwdnEUOKZwXYztIflZccH3UnIZqEoCA76BiKbyQxqouXTZVNUzS ojCFeu7apBPm7P7dAPeGkm6ozqhfv/NjEV1rdL6eP8EprLjIUe2fu8suaRwAy+wtvaSQ MlmBVeLmrjQ9xM6tShbUUHnU/10wOirNPiYBQZmyd2P6iQXj18Turf2lZB1htQzO4o8I neY2LWS1WpjlyPsr1MmP/2X6IpwT87k6jWAxIJJqkZPpDvr9+hE+3VfSaetsa+lB9S7u NOacbRtbgjIox6ISkfH0cDVmKancxGN4uth0ryrKE90j/lnU7Afv7ROMkHVSaJ7YtgNv URng== X-Received: by 10.50.142.40 with SMTP id rt8mr13208154igb.28.1452144829364; Wed, 06 Jan 2016 21:33:49 -0800 (PST) In-Reply-To: X-Content-Filtered-By: Mailman/MimeDel 2.1.20+ X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:101320 On Wed, Jan 6, 2016 at 11:59 PM, Grobu 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