Skip to content

Commit 01e541b

Browse files
Fix #41: renamed single character variables
1 parent 5519ac8 commit 01e541b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

docs/readability/not_using_a_dict_comprehension.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ The code below demonstrates the old syntax of dict initialization. Although ther
1010

1111
.. code:: python
1212
13-
l = [1,2,3]
13+
numbers = [1,2,3]
1414
15-
d = dict([(n,n*2) for n in l]) # hard to read
15+
my_dict = dict([(number,number*2) for number in numbers]) # hard to read
1616
17-
print d # {1: 2, 2: 4, 3: 6}
17+
print my_dict # {1: 2, 2: 4, 3: 6}
1818
1919
Best practice
2020
-------------
@@ -23,11 +23,11 @@ The modified code below uses the new dict comprehension syntax which was introdu
2323

2424
.. code:: python
2525
26-
l = [1, 2, 3]
26+
numbers = [1, 2, 3]
2727
28-
d = {n: n * 2 for n in l}
28+
my_dict = {number: number * 2 for number in numbers}
2929
30-
print d # {1: 2, 2: 4, 3: 6}
30+
print my_dict # {1: 2, 2: 4, 3: 6}
3131
3232
References
3333
----------

0 commit comments

Comments
 (0)