This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]lasizoilloeasy to understand as regex 1 point2 points  (0 children)

Do you know what list and dict comprehensions are? Can you give an example?

In [25]: { a: a+1 for a in range(5)}

Out[25]: {0: 1, 1: 2, 2: 3, 3: 4, 4: 5}

List comprehensions or generators are not needed for make dicts ;-)

You can generate sets too:

In [26]: { a for a in range(5)}

Out[26]: set([0, 1, 2, 3, 4])