Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ian Kelly Newsgroups: comp.lang.python Subject: Re: What is a function parameter =[] for? Date: Tue, 24 Nov 2015 09:56:02 -0700 Lines: 44 Message-ID: References: <564dbe6b$0$1610$c3e8da3$5496439d@news.astraweb.com> <564df258$0$1604$c3e8da3$5496439d@news.astraweb.com> <8601c9af-a7d9-4642-ba1c-8edd1e4c3390@googlegroups.com> <56546985.8060704@rece.vub.ac.be> <56547337.4000709@rece.vub.ac.be> <56547C53.8030407@rece.vub.ac.be> <5654864E.2070906@rece.vub.ac.be> <56549324.8020607@rece.vub.ac.be> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de 0lq8oZiOk6ATMiRrdFPOPQzTJLgYNCqjT7RWN94LZHYg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.015 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'identifier,': 0.09; 'literal': 0.09; 'python:': 0.09; 'def': 0.13; '24,': 0.16; 'enumerates': 0.16; 'grounds': 0.16; 'literal,': 0.16; 'literal.': 0.16; 'literals': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'byte': 0.18; '2015': 0.20; 'meant': 0.22; 'constant': 0.22; 'either.': 0.22; 'produces': 0.22; 'am,': 0.23; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'chris': 0.26; 'message-id:@mail.gmail.com': 0.27; 'argue': 0.29; 'code:': 0.29; "i'm": 0.30; 'code': 0.30; 'related': 0.32; 'url:python': 0.33; 'point,': 0.33; 'though.': 0.33; 'tue,': 0.34; 'gets': 0.35; 'received:google.com': 0.35; 'nov': 0.35; 'url:org': 0.36; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'sure': 0.39; 'rather': 0.39; 'to:addr:python.org': 0.40; 'url:3': 0.60; 'is.': 0.63; 'angelico:': 0.84; 'pardon': 0.84; 'schreef': 0.84; 'to:name:python': 0.84; 'url:reference': 0.91 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=m29Xj6Z8gPt+8bqLt2l55c6/+c6Wcdxfux4u0Gt8fR4=; b=pUstYmjoZVlUfJEIjTy3oV3vJ+2+0sMcQVeGYyi5m+0JfJl1zvglONyi4WclvrT1Go 9gbRzC1nUAV0goXTv+wJVxwjCTp6itKCnLjPYDX4GpOIkxF0F21X2zb6HNE5b6coIrzc zOA6pIgVWar8FMr61/AGeaZRakbbdNzlN8KDjDFkxfDlmbYpQjisPG4oVVhl8F21iHan 9qLI7ahcXSAD/a7vSqi+CmwQv2D8J4x4xhs5Up/BvcyXIbgUFJPG7MX3DwDEroU+lwD5 2A/xPEq9Aii0A58lUcZ7bkN1NXxWcSEXD5t3QkAASstA0OrUpaagkFcNw315bBbVjyC0 d1Mg== X-Received: by 10.50.73.130 with SMTP id l2mr7265208igv.93.1448384201593; Tue, 24 Nov 2015 08:56:41 -0800 (PST) In-Reply-To: <56549324.8020607@rece.vub.ac.be> 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:99368 On Tue, Nov 24, 2015 at 9:41 AM, Antoon Pardon wrote: > Op 24-11-15 om 16:48 schreef Chris Angelico: >> () is not a literal either. > > The byte code sure suggests it is. > > Take the following code: > > import dis > > def f(): > i = 42 > t = () > l = [] > > dis.dis(f) > > That produces the following: > > > 4 0 LOAD_CONST 1 (42) > 3 STORE_FAST 0 (i) > > 5 6 LOAD_CONST 2 (()) > 9 STORE_FAST 1 (t) > > 6 12 BUILD_LIST 0 > 15 STORE_FAST 2 (l) > 18 LOAD_CONST 0 (None) > 21 RETURN_VALUE I'm not sure what this is meant to prove. None is clearly an identifier, not a literal, and it also gets treated as a constant in the code above. > So on what grounds would you argue that () is not a literal. This enumerates exactly what literals are in Python: https://docs.python.org/3/reference/lexical_analysis.html#literals I think it's a rather pedantic point, though. How are nuances of the grammar at all related to user expectations?