Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed2.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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python3': 0.07; 'received:internal': 0.09; 'subtle': 0.09; 'python': 0.11; 'def': 0.12; '(k,': 0.16; 'foo()': 0.16; 'kwargs': 0.16; 'message- id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:messagingengine.com': 0.16; 'repr': 0.16; 'set()': 0.16; 'set,': 0.16; 'subject:Java': 0.16; 'subtlety': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'example': 0.22; 'mon,': 0.24; 'subject:/': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'andrew': 0.30; 'url:mailman': 0.30; 'consequence': 0.31; 'linux': 0.33; 'url:python': 0.33; 'received:66': 0.35; 'url:listinfo': 0.36; 'url:org': 0.36; 'received:10': 0.37; 'to:addr:python-list': 0.38; 'fact': 0.38; 'to:addr:python.org': 0.39; 'url:mail': 0.40; 'from:no real name:2**0': 0.61; "you've": 0.63; 'header:Message-Id:1': 0.63; 'more': 0.64; '2014,': 0.84; 'dict.': 0.84; 'subject:experience': 0.84 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.us; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=cRMOjPpcdFkFdR26+MFT5I4Ccj4=; b=rP0Fl/ A0wulrd4bZKqppo7yNYEHydJPDMEKR+v9K5UBMKnUvwxKEKbo6p4ovX9NHcXsU7I HttcdEOdz2usJIvC0JPgP/oDxrNArbUo20dcHJd+Wy4dsCq0W4BiUiYsGGVxfbvp 37kRZ+GvnYdHCuDS4rCMTjg9dsUox4kQp2f4U= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=cRMOjPpcdFkFdR2 6+MFT5I4Ccj4=; b=q64BS0SMbbLdlwhlSxS/S4qUC6jcNdwjNonXDUb8iNqOZ2H WkaHnyDCXjn3LdZvGZuDHiVevXd1Uf+FYYuiw65l4pxBcdX7T2hXtZIkh4R9AgfB SzwxEimsjV8LVeOD+gw8HW36aExBP8/vXXptg8gObrvptWO7y6DQOS/R0zkI= X-Sasl-Enc: o+rEBACIVPkh5IF6p7JUSUWHXH1McgXN3SW2lBtAXF/e 1430774163 From: random832@fastmail.us To: python-list@python.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Mailer: MessagingEngine.com Webmail Interface - ajax-f5f4dd6c Subject: Re: Bitten by my C/Java experience Date: Mon, 04 May 2015 17:16:03 -0400 In-Reply-To: References: <87r3qwid3u.fsf@Equus.decebal.nl> 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: 33 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1430774166 news.xs4all.nl 2913 [2001:888:2000:d::a6]:54419 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:89937 On Mon, May 4, 2015, at 16:57, Andrew Cooper wrote: > * {} is an empty set(), not dict(). You've got it backwards. > Particularly subtle when combined with **kwargs The function in your example below _always_ returns a set, and kwargs is always a dict. There's no subtlety outside of the repr output. The fact that the empty set (as a result of empty kwargs) repr's as set() is a consequence of the fact that {} is a dict. > > $ python3 > Python 3.4.0 (default, Apr 11 2014, 13:05:11) > [GCC 4.8.2] on linux > Type "help", "copyright", "credits" or "license" for more information. > >>> def foo(**kwargs): > ... return { (k, kwargs[k]) for k in kwargs } > ... > >>> foo() > set() > >>> foo(a=1) > {('a', 1)} > >>> > > ~Andrew > -- > https://mail.python.org/mailman/listinfo/python-list -- Random832