Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #3704
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail |
|---|---|
| From | Mel <mwilson@the-wire.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: List comprehension vs filter() |
| Followup-To | comp.lang.python |
| Date | Wed, 20 Apr 2011 10:12:21 -0400 |
| Organization | Aioe.org NNTP Server |
| Lines | 16 |
| Message-ID | <iompk3$2ef$1@speranza.aioe.org> (permalink) |
| References | <BANLkTin4KMcoWzfH64Eu=+sD9=M3TaAu2A@mail.gmail.com> <BANLkTinVhX1jDd5brOh1D1m4zU5R8pEoSQ@mail.gmail.com> <BANLkTimvUPXRKOvGNqDzNCJp0UuWT1AkVg@mail.gmail.com> <BANLkTimmfwZ5dB+Vt8S2-rYAwS4axvn8og@mail.gmail.com> <mailman.611.1303271986.9059.python-list@python.org> <lt1tq6hq1oo39n0tl87evb1vi8cj841vqu@4ax.com> <mailman.629.1303288571.9059.python-list@python.org> |
| Reply-To | mwilson@the-wire.com |
| NNTP-Posting-Host | dABE/dRgL5GIkzqwrI5tGA.user.speranza.aioe.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1" |
| Content-Transfer-Encoding | 7Bit |
| X-Complaints-To | abuse@aioe.org |
| User-Agent | KNode/4.4.8 |
| X-Notice | Filtered by postfilter v. 0.8.2 |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:3704 |
Followups directed to: comp.lang.python
Show key headers only | View raw
Chris Angelico wrote: > On Wed, Apr 20, 2011 at 5:16 PM, Tim Roberts <timr@probo.com> wrote: >> You can solve this through the common lamba idiom of a closure: >> >> lst=filter(lambda x,posttype=posttype: x["type"].lower()==posttype,lst) > > Seems a little odd, but sure. I guess this means that a function's > default arguments are evaluated in the parent context, but the body is > evaluated in its own context? The operation of calling a function has to evaluate arguments provided in the caller's namespace and assign them to variables in the called function's namespace. Yes. Mel.
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar
Re: List comprehension vs filter() Chris Angelico <rosuav@gmail.com> - 2011-04-20 13:59 +1000
Re: List comprehension vs filter() Tim Roberts <timr@probo.com> - 2011-04-20 00:16 -0700
Re: List comprehension vs filter() Chris Angelico <rosuav@gmail.com> - 2011-04-20 18:36 +1000
Re: List comprehension vs filter() Mel <mwilson@the-wire.com> - 2011-04-20 10:12 -0400
csiph-web