Skip to content

Commit 07cfb81

Browse files
committed
2 parents b953f48 + 7e948b0 commit 07cfb81

4 files changed

Lines changed: 8 additions & 12 deletions

File tree

args_and_kwargs.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
I have come to see that most new python programmers have a hard time
55
figuring out the \*args and \*\*kwargs magic variables. So what are they
66
? First of all let me tell you that it is not necessary to write \*args
7-
or \*\*kwargs. Only the ``*`` (aesteric) is necessary. You could have
7+
or \*\*kwargs. Only the ``*`` (asterisk) is necessary. You could have
88
also written \*var and \*\*vars. Writing \*args and \*\*kwargs is just a
99
convention. So now lets take a look at \*args first.
1010

collections.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ not. So we can do:
3434
3535
favourite_colours = defaultdict(list)
3636
37-
for name, colour in order:
37+
for name, colour in colours:
3838
favourite_colours[name].append(colour)
3939
4040
print(favourite_colours)

comprehensions.rst

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ recently:
6767
.. code:: python
6868
6969
mcase = {'a': 10, 'b': 34, 'A': 7, 'Z': 3}
70-
70+
7171
mcase_frequency = {
7272
k.lower(): mcase.get(k.lower(), 0) + mcase.get(k.upper(), 0)
7373
for k in mcase.keys()
7474
}
75-
75+
7676
# mcase_frequency == {'a': 17, 'z': 3, 'b': 34}
7777
7878
In the above example we are combining the values of keys which are same
@@ -87,14 +87,10 @@ comprehensions a lot. You can also quickly switch keys and values of a dictionar
8787
^^^^^^^^^^^^^^^^^^^^^^
8888

8989
They are also similar to list comprehensions. The only difference is
90-
that they use round brackets ``()`` and return a generator. Here is an
91-
example:
90+
that they use braces ``{}``. Here is an example:
9291

9392
.. code:: python
9493
95-
squared = (x**2 for x in range(10))
94+
squared = {x for x in [1, 1, 2]}
9695
print(squared)
97-
# Output: <generator object <genexpr> at 0x00000000029931B0>
98-
squared.next()
99-
# Output: 0
100-
96+
# Output: {1, 2}

ternary_operators.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ expressions.
1212

1313
.. code:: python
1414
15-
condition_is_true if condition_true else condition_is_false
15+
condition_is_true if condition else condition_is_false
1616
1717
**Example:**
1818

0 commit comments

Comments
 (0)