Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #100044
| Path | csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Peter Pearson <pkpearson@nowhere.invalid> |
| Newsgroups | comp.lang.python |
| Subject | Re: filter a list of strings |
| Date | 5 Dec 2015 19:42:04 GMT |
| Lines | 16 |
| Message-ID | <dcgt0cF9d3fU2@mid.individual.net> (permalink) |
| References | <mailman.155.1449122975.14615.python-list@python.org> <lf51tb459f2.fsf@ling.helsinki.fi> <mailman.165.1449134847.14615.python-list@python.org> |
| X-Trace | individual.net 0kFWoo3hk4dIvdXpXLpfGQVsfj7ZBhNmpz/6zEnSakHoU1mBK3 |
| Cancel-Lock | sha1:4d3XxvLbYcluG689xYbHfPSfU7Y= |
| User-Agent | slrn/pre1.0.0-18 (Linux) |
| Xref | csiph.com comp.lang.python:100044 |
Show key headers only | View raw
On Thu, 3 Dec 2015 10:27:19 +0100, <c.buhtz@posteo.jp> wrote: [snip] > I often saw constructions like this > x for x in y if ... > But I don't understand that combination of the Python keywords (for, > in, if) I allready know. It is to complex to imagine what there really > happen. Don't give up! List comprehensions are one of the coolest things in Python. Maybe this simple example will make it click for you: >>> [x**2 for x in [1,2,3,4] if x != 2] [1, 9, 16] -- To email me, substitute nowhere->runbox, invalid->com.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
filter a list of strings <c.buhtz@posteo.jp> - 2015-12-03 02:15 +0100
Re: filter a list of strings Jussi Piitulainen <harvesting@is.invalid> - 2015-12-03 08:32 +0200
Re: filter a list of strings <c.buhtz@posteo.jp> - 2015-12-03 10:27 +0100
Re: filter a list of strings Jussi Piitulainen <harvesting@is.invalid> - 2015-12-03 13:53 +0200
Re: filter a list of strings Peter Pearson <pkpearson@nowhere.invalid> - 2015-12-05 19:42 +0000
Re: filter a list of strings Chris Angelico <rosuav@gmail.com> - 2015-12-03 20:40 +1100
Re: filter a list of strings Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2015-12-03 10:46 +0100
Re: filter a list of strings Laura Creighton <lac@openend.se> - 2015-12-03 10:53 +0100
Re: filter a list of strings jmp <jeanmichel@sequans.com> - 2015-12-03 11:03 +0100
Re: filter a list of strings Peter Otten <__peter__@web.de> - 2015-12-03 11:13 +0100
Re: filter a list of strings Denis McMahon <denismfmcmahon@gmail.com> - 2015-12-03 14:16 +0000
Re: filter a list of strings Jussi Piitulainen <harvesting@is.invalid> - 2015-12-03 17:02 +0200
Re: filter a list of strings Grobu <snailcoder@retrosite.invalid> - 2015-12-03 13:17 +0100
csiph-web