Path: csiph.com!goblin3!goblin.stu.neva.ru!panix!gordon From: John Gordon Newsgroups: comp.lang.python Subject: Re: What is a function parameter =[] for? Date: Wed, 18 Nov 2015 22:05:19 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 25 Message-ID: References: NNTP-Posting-Host: panix1.panix.com X-Trace: reader1.panix.com 1447884319 19885 166.84.1.1 (18 Nov 2015 22:05:19 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Wed, 18 Nov 2015 22:05:19 +0000 (UTC) User-Agent: nn/6.7.3 Xref: csiph.com comp.lang.python:99002 In fl writes: > Hi, > I have tried the below function and find that it can remember the previous > setting value to 'val'. I think the second parameter has something on this > effect, but I don't know the name and function of '=[]' in this application. > Could you explain a little to me? > Thanks, > def eList(val, list0=[]): > list0.append(val) > return list0 > list1 = eList(12) > list1 = eList('a') That is a default parameter. If eList() is called without an argument for list0, it will use [] as the default value. -- John Gordon A is for Amy, who fell down the stairs gordon@panix.com B is for Basil, assaulted by bears -- Edward Gorey, "The Gashlycrumb Tinies"