4 ms·
Python has map comprehensions like this: {i: i+1 for i in range(10)} Works pretty well.
by thomasahle 12y ago
Python has map comprehensions like this:
{i: i+1 for i in range(10)}
Works pretty well.
- deleted 12y ago[deleted]
- jmgrosen 12y agoPerhaps more comparable to the comprehensions shown in this post would be generator comprehensions: list(p.first_name + " " + p.last_name for p in people) dict((p.first_name + " " + p.last_name, p) for p in people) set(j.organization for p in people for j in p.jobs) print(", ".join(p.first_name + " " + p.last_name for p in people)) (Of course, Python has sugar for the first three.)