Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: 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; 'partial': 0.05; 'bool': 0.09; 'lambda:': 0.09; 'target,': 0.09; 'pm,': 0.11; '25,': 0.12; 'wrote:': 0.14; '**kwargs)': 0.16; '**kwargs):': 0.16; '*args,': 0.16; 'better:': 0.16; 'functools': 0.16; 'rachel': 0.16; 'subject:function': 0.16; '\xa0def': 0.16; 'cc:no real name:2**0': 0.20; 'cc:2**0': 0.20; 'cheers,': 0.20; 'maybe': 0.21; 'header:In- Reply-To:1': 0.22; 'cc:addr:python-list': 0.22; 'mon,': 0.22; 'received:209.85.161.46': 0.26; 'received:mail- fx0-f46.google.com': 0.26; 'function': 0.27; 'message- id:@mail.gmail.com': 0.28; 'received:209.85.161': 0.29; 'class': 0.29; 'yet': 0.30; 'cc:addr:python.org': 0.31; 'import': 0.32; '...': 0.32; 'received:209.85': 0.37; 'apr': 0.38; 'received:google.com': 0.38; 'end': 0.39; 'received:209': 0.39; 'header:Received:5': 0.40; 'order': 0.61; '2011': 0.62; 'care': 0.67; 'schrieb': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type:content-transfer-encoding; bh=lCbOxkVkee0bQKhoZbB2k/5+xVOVyyCqQvJkuz5Fsyo=; b=pA7XuECCTwNeTpkIdBiugnkXZCRxuUOIdoyIniy6dqBz2SVs4cTtTte+jn7wFA2JqN s+CxVOphqWhMOPgorQrqdLXmSnC+BLUTOxc7rK7b/QHyA1ckbYiJ2ouC+vY+sg7pqVEw oXL58xwzZe/ZCNHWJyrLOqPtb9pB5UwW8V/lA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type:content-transfer-encoding; b=GzE2QL2OipsA4sH9AkbUC7byiwkKeg5Xh4yNtigTYvx80a3L0dFOhCn1OTMBUOtB04 7lbhxahDMah1EXopAXmP8GDPyFFOqkXlihe07jsYj3PgV86XUo1+0A4MGqjpbc12hl6/ /+xOfjvFUkrjYJ5QjqrucytW7h3cOkWqdgHZc= MIME-Version: 1.0 In-Reply-To: References: <4d9f374b$0$12803$426a34cc@news.free.fr> <4da1a8b5$0$23679$426a74cc@news.free.fr> From: Ian Kelly Date: Mon, 25 Apr 2011 17:44:38 -0600 Subject: Re: Argument of the bool function To: Thomas Rachel Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 34 NNTP-Posting-Host: 82.94.164.166 X-Trace: 1303775110 news.xs4all.nl 41114 [::ffff:82.94.164.166]:48236 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:4008 On Mon, Apr 25, 2011 at 3:28 PM, Thomas Rachel wrote: > Am 25.04.2011 16:29, schrieb Thomas Rachel: > >> or maybe even better (taking care for closures): >> >> function =3D bool >> value =3D 'the well at the end of the world' >> ## ... >> actions.append(lambda val=3Dvalue: function(val)) >> ## ... >> for function in actions: >> results.append(function()) > > Or yet even better: > > class Job(object): > =A0 =A0def __init__(self, target, *args, **kwargs): > =A0 =A0 =A0 =A0self.target =3D lambda: target(*args, **kwargs) > =A0 =A0def __call__(self): > =A0 =A0 =A0 =A0return self.target() > > in order to do > > actions.append(Job(function, val)) > actions.append(Job(function, x=3Dval)) from functools import partial actions.append(partial(function, val)) actions.append(partial(function, x=3Dval)) Cheers, Ian