Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed0.kamp.net!newsfeed.kamp.net!feeder1.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.83.MISMATCH!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'operator': 0.03; '*not*': 0.07; 'element': 0.07; 'methods,': 0.09; 'subject:set': 0.09; 'accepting': 0.14; 'dependent.': 0.16; 'iterable': 0.16; 'elements': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'documented': 0.24; 'versions': 0.24; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'generally': 0.29; 'tim': 0.29; 'subject:list': 0.30; 'message- id:@mail.gmail.com': 0.30; 'python2.7': 0.31; 'noticed': 0.34; 'except': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'set.': 0.36; 'list': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'today,': 0.61; '30,': 0.65; '2015': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=hgr/d7xykxKWkozTr4lcf3j/7PvroAruWni8hkooEK8=; b=osJMUwAVMU4d94aqp+s3Q5NbZGu3nrfPtU7pBUOfCWGHwZ5dfHiBEtqtv1g1JzFwLn ixXW1dazsF+Tx+HLP7f8UHwdm9RIdlouyE0RsNAroZ84dMk1p5wQQkRRIx2RnTLevhYs +u4zpEKDcwR5+YUNhyYmZACHPW8YAoxpKOhAYJeGOOBpOUSBHXXBO2LpSnw84tg/YrPs z9rr+MRbTtj7X+a4sm8+Fz/yESIQx/l/N5s9H/Y/egVTIddWxXbTN6qeVp/dzJs0dpir cz6mnpZ6WjYylev1EcSUSDbuq11i93Ilmm6ygg5KOr72MTDpbL4qAmBvuWxCzOUvdU61 MTpw== X-Received: by 10.43.64.144 with SMTP id xi16mr10464379icb.20.1430410902479; Thu, 30 Apr 2015 09:21:42 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <7f1dc7d2-2f88-4b1e-b3ae-bb67ae7e0028@googlegroups.com> References: <7f1dc7d2-2f88-4b1e-b3ae-bb67ae7e0028@googlegroups.com> From: Ian Kelly Date: Thu, 30 Apr 2015 10:21:02 -0600 Subject: Re: mixing set and list operations To: Python Content-Type: text/plain; charset=UTF-8 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: , Newsgroups: comp.lang.python Message-ID: Lines: 14 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1430410904 news.xs4all.nl 2884 [2001:888:2000:d::a6]:48982 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:89637 On Thu, Apr 30, 2015 at 10:07 AM, Tim wrote: > I noticed this today, using Python2.7 or 3.4, and wondered if it is implementation dependent: > > You can use 'extend' to add set elements to a list and use 'update' to add list elements to a set. It's not implementation dependent. Both methods are documented as accepting arbitrary iterables. The same is also true for the other foo_update set methods (and is generally true of built-ins). It is *not* true for the operator versions of the set methods, however (|, -, &, ^). It's also true for dict.update, except that in this case if an iterable is passed instead of a map, then each element of the iterable must be a 2-element iterable.