Top "List-comprehension" questions

A syntactic construct which provides a concise way to create lists in a style similar to the mathematical set-builder notation.

How to parallelize list-comprehension calculations in Python?

Both list comprehensions and map-calculations should -- at least in theory -- be relatively easy to parallelize: each calculation inside …

python parallel-processing list-comprehension
Why doesn't Pylint like built-in functions?

I have a line like this: filter(lambda x: x == 1, [1, 1, 2]) Pylint is showing a warning: W: 3: Used builtin function 'filter' …

python list-comprehension pylint
python - iterating list of dictionaries and unpacking

Given a flat list of simple dictionaries lst = [{'key1': 1}, {'key2': 2}, {'key3': 3}] I'd like to find the dict …

python python-3.x list-comprehension argument-unpacking
Python list comprehension, unpacking and multiple operations

I want to unpack the tuples I create by doing the following so he the result is just one simple …

python tuples list-comprehension flatten
Filter with CoffeeScript list comprehensions

The CoffeeScript docs state that list comprehensions should be able to do the select/filter operations: They should be able …

list-comprehension coffeescript
list.extend and list comprehension

When I need to add several identical items to the list I use list.extend: a = ['a', 'b', 'c'] a.…

python list list-comprehension
Comprehension for flattening a sequence of sequences?

If I have sequence of sequences (maybe a list of tuples) I can use itertools.chain() to flatten it. But …

python sequences list-comprehension
Using while in list comprehension or generator expressions

I can use if and for in list comprehensions/generator expressions as list(i for i in range(100) if i*…

python list-comprehension recipe generator-expression
Accessing class variables from a list comprehension in the class definition

How do you access other class variables from a list comprehension within the class definition? The following works in Python 2 …

python python-3.x scope list-comprehension python-internals