Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Antoon Pardon Newsgroups: comp.lang.python Subject: Re: What is a function parameter =[] for? Date: Tue, 24 Nov 2015 17:41:08 +0100 Lines: 48 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> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de zn/zdYo4Hb/h5yTO6GQwZQL3BV7WGIFreeUKtAdCLjTw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.028 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'expressions': 0.07; 'literal': 0.09; 'def': 0.13; 'wed,': 0.15; 'grounds': 0.16; 'literal.': 0.16; 'literals': 0.16; 'received:adsl- dyn.isp.belgacom.be': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'recognizable': 0.16; 'wrote:': 0.16; 'byte': 0.18; '2015': 0.20; 'either.': 0.22; 'produces': 0.22; 'am,': 0.23; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'header :User-Agent:1': 0.26; "doesn't": 0.26; 'chris': 0.26; 'looks': 0.29; 'argue': 0.29; 'received:192.168.1.3': 0.29; 'code:': 0.29; 'code': 0.30; 'received:be': 0.30; 'point': 0.33; 'similar': 0.33; 'list': 0.34; 'nov': 0.35; "isn't": 0.35; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'being': 0.37; 'say': 0.37; 'sure': 0.39; 'easily': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'charset:windows-1252': 0.62; 'is.': 0.63; 'more': 0.63; 'angelico:': 0.84; 'beside': 0.84; 'pardon': 0.84; 'received:195.238': 0.84; 'schreef': 0.84 X-Belgacom-Dynamic: yes X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2CWAQC3klRW/9Xi9VENUYR9wRyGDwKBfRABAQEBAQEBhT8BAQR4EQsYCRYPCQMCAQIBRRMGAgKIL61GjHqEJgEBCAIBIIZUhH6FJ4QSAQSWUI0xgVuWfoNyOIQwcQGFKgEBAQ User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.8.0 In-Reply-To: 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:99366 Op 24-11-15 om 16:48 schreef Chris Angelico: > On Wed, Nov 25, 2015 at 2:46 AM, Antoon Pardon > wrote: >> What is your point? I say that [] looks like a literal. Because it >> sure resembles () which is a literal. >> >> That [] in fact isn't a literal doesn't contradict it looks like >> one. >> >> That you can come up with more complicated list expressions that >> are more easily recognizable as not being literals is beside the >> point because we have generator expressions that look similar to >> those list comprehensions and those generator expressions don't >> contradict that () is a literal. > > () 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 So on what grounds would you argue that () is not a literal. -- Antoon.