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 10:53:44 -0700 Lines: 33 Message-ID: References: <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> <56549F15.40206@rece.vub.ac.be> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de k9Kp+iror+TSYj4fC8jZ8wsDcY1fr9f8Be5Og4zoBj+Q== 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; 'received:209.85.223': 0.03; 'defines': 0.07; 'definition,': 0.09; 'indeed,': 0.09; 'optional': 0.09; 'python:': 0.09; '24,': 0.16; 'enumerates': 0.16; 'grounds': 0.16; 'lexical': 0.16; 'literal.': 0.16; 'literals': 0.16; 'notations': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'token,': 0.16; 'wrote:': 0.16; 'byte': 0.18; '>>>': 0.20; '2015': 0.20; 'constant': 0.22; 'am,': 0.23; 'header:In-Reply-To:1': 0.24; 'followed': 0.27; 'message- id:@mail.gmail.com': 0.27; 'specifically': 0.28; 'values': 0.28; 'argue': 0.29; 'types.': 0.29; 'starts': 0.29; 'code': 0.30; 'related': 0.32; 'point': 0.33; 'url:python': 0.33; 'point,': 0.33; 'though.': 0.33; 'tue,': 0.34; 'list': 0.34; 'received:google.com': 0.35; 'confirmed': 0.35; 'displays': 0.35; 'nov': 0.35; 'too': 0.36; 'url:org': 0.36; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'being': 0.37; 'received:209': 0.38; 'rather': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'url:3': 0.60; 'limited.': 0.67; 'therefore': 0.67; '10:32': 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=rMcSKfv3GmLqC2/dj2AFpoV5a5I2zS4PDAZlYt9jijY=; b=CN2ZW1lsRmLy6m5ERnaEEqTQmeEmbWZlGbqr2Y+2E5aKya1ICpkTAgOMyVuxNnN70v DiL2wQ6Lf3+AcwszVyYTY23QabnWvbi5XzPlcEjwJYtraV/wnaSQEb790TTQAI4Whgs9 VqlvNsOB9ab13cKltoddVoPl9oQhD0KG4/qQ3IR8Y5C+tZaEqMmVg2AReUfcI8Sh5sc/ E6scCqaApKG8X562o+6VMjF7DLk8wAEzux7YwLTZGld7GlKuuhhkCIFq/oWwK9I8l16N HceQP+XIoxQUMD+PBnMrcDG8DlruyFrZhTUoI0btoHaA0bLdCY7gaZjoXaTZ4EvHqJvM s4sQ== X-Received: by 10.107.137.226 with SMTP id t95mr30699856ioi.188.1448387664046; Tue, 24 Nov 2015 09:54:24 -0800 (PST) In-Reply-To: <56549F15.40206@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:99377 On Tue, Nov 24, 2015 at 10:32 AM, Antoon Pardon wrote: > Op 24-11-15 om 17:56 schreef Ian Kelly: > >> >>> 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? >> > > I think that enumaration is too limited. The section starts with: > > Literals are notations for constant values of some built-in types. > > () satisfies that definition, which is confirmed by the byte code > produced for it. Literals are a type of lexical token. All of the literals shown in that section are, indeed, tokens. Now I would point you to the grammar specification: https://docs.python.org/3/reference/grammar.html And specifically the "atom" rule, which defines both list displays and list comprehensions (as well as literals) as being atoms. Specifically, it parses () as the token '(', followed by an optional yield_expr or testlist_comp, followed by the token ')'. In no way is that a single token, nor therefore a literal.