Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #82161

Re: Question on lambdas

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'parameters': 0.04; 'syntax': 0.04; 'subject:Question': 0.07; 'function,': 0.09; 'parameter': 0.09; 'cc:addr:python-list': 0.11; 'creates': 0.14; 'called,': 0.16; 'expects': 0.16; 'finney': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'lambda': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'am,': 0.29; 'dec': 0.30; 'forgot': 0.30; 'message- id:@mail.gmail.com': 0.30; 'received:google.com': 0.35; 'ben': 0.38; 'skip:x 10': 0.40; 'new': 0.61; 'skip:\xe2 10': 0.65; 'default': 0.69; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=za1JKVI26Ht7slHFfNkeE8S+2thIb4wZxDWQDxMiJto=; b=IlfKwHqkehlIF3gcaFRxMjvKCzofY9hhGDOzZtlv3NdniWyPNGT/U6sGwN/UX9Jdxq Tj2caS8CMnikjjzgJs+UwRrwrJIBxU3Bi/6Z9CN6aT0C69zFnlXUpGrwEWTUg9XIY7WS P98C7CC/jO5IPF1pzn1Aast/k9Qcg3PppewFOL+4XzELsAsHX5jETUyCvatQufEmATSo mNAmNyySafh93xBQ7Bnf2FoDbnPoT+LKYn1GOVu6Tp97eYLHoR84dFAesVw5s976THRM iscOmrounYRIAPY8umaB6KdJYDxx6rOLcuoBBM5xNU0jWuAnoQ8RbTRLdw1oStNML+al JCdQ==
MIME-Version 1.0
X-Received by 10.50.62.104 with SMTP id x8mr17689918igr.2.1418083248651; Mon, 08 Dec 2014 16:00:48 -0800 (PST)
In-Reply-To <85oarditil.fsf@benfinney.id.au>
References <m65d2m$3pe$1@ger.gmane.org> <85oarditil.fsf@benfinney.id.au>
Date Tue, 9 Dec 2014 11:00:48 +1100
Subject Re: Question on lambdas
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.16747.1418083251.18130.python-list@python.org> (permalink)
Lines 15
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1418083251 news.xs4all.nl 2830 [2001:888:2000:d::a6]:35622
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:82161

Show key headers only | View raw


On Tue, Dec 9, 2014 at 10:58 AM, Ben Finney <ben+python@benfinney.id.au> wrote:
>> lambda x=some_value: some_expr
>
> This creates a new function which expects one parameter named ‘x’, which
> parameter has a default value of ‘some_value’. The function, when
> called, will return the value of ‘some_expr’.

*facepalm* For some reason I forgot about default parameters _inside_
the lambda function, and thought only of named parameters _outside_
it. Ben's right, that's what your "lambda e=e:" syntax is doing.

ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Question on lambdas Chris Angelico <rosuav@gmail.com> - 2014-12-09 11:00 +1100

csiph-web