Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #3704
| From | Mel <mwilson@the-wire.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: List comprehension vs filter() |
| Followup-To | comp.lang.python |
| Date | 2011-04-20 10:12 -0400 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <iompk3$2ef$1@speranza.aioe.org> (permalink) |
| References | (2 earlier) <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> |
Followups directed to: comp.lang.python
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