Skip to content

Commit 043b83a

Browse files
authored
Minor README fixups
1 parent 2e2d65a commit 043b83a

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ True
449449
450450
```py
451451
>>> a, b = 257, 257
452-
>> a is b
452+
>>> a is b
453453
False
454454
```
455455
@@ -917,7 +917,7 @@ array_4 = [400, 500, 600]
917917
- In a [generator](https://wiki.python.org/moin/Generators) expression, the `in` clause is evaluated at declaration time, but the conditional clause is evaluated at runtime.
918918
- So before runtime, `array` is re-assigned to the list `[2, 8, 22]`, and since out of `1`, `8` and `15`, only the count of `8` is greater than `0`, the generator only yields `8`.
919919
- The differences in the output of `g1` and `g2` in the second part is due the way variables `array_1` and `array_2` are re-assigned values.
920-
- In the first case, `array_1` is binded to the new object `[1,2,3,4,5]` and since the `in` clause is evaluated at the declaration time it still refers to the old object `[1,2,3,4]` (which is not destroyed).
920+
- In the first case, `array_1` is bound to the new object `[1,2,3,4,5]` and since the `in` clause is evaluated at the declaration time it still refers to the old object `[1,2,3,4]` (which is not destroyed).
921921
- In the second case, the slice assignment to `array_2` updates the same old object `[1,2,3,4]` to `[1,2,3,4,5]`. Hence both the `g2` and `array_2` still have reference to the same object (which has now been updated to `[1,2,3,4,5]`).
922922
- Okay, going by the logic discussed so far, shouldn't be the value of `list(gen)` in the third snippet be `[11, 21, 31, 12, 22, 32, 13, 23, 33]`? (because `array_3` and `array_4` are going to behave just like `array_1`). The reason why (only) `array_4` values got updated is explained in [PEP-289](https://www.python.org/dev/peps/pep-0289/#the-details)
923923
@@ -1841,9 +1841,9 @@ NameError: name 'e' is not defined
18411841
18421842
**Output:**
18431843
```py
1844-
>>>f(x)
1844+
>>> f(x)
18451845
UnboundLocalError: local variable 'x' referenced before assignment
1846-
>>>f(y)
1846+
>>> f(y)
18471847
UnboundLocalError: local variable 'x' referenced before assignment
18481848
>>> x
18491849
5
@@ -2753,7 +2753,7 @@ def similar_recursive_func(a):
27532753
27542754
* As for the fifth snippet, most methods that modify the items of sequence/mapping objects like `list.append`, `dict.update`, `list.sort`, etc. modify the objects in-place and return `None`. The rationale behind this is to improve performance by avoiding making a copy of the object if the operation can be done in-place (Referred from [here](https://docs.python.org/3/faq/design.html#why-doesn-t-list-sort-return-the-sorted-list)).
27552755
2756-
* Last one should be fairly obvious, mutable object (like `list`) can be altered in the function, and the reassignation of an immutable (`a -= 1`) is not an alteration of the value.
2756+
* Last one should be fairly obvious, mutable object (like `list`) can be altered in the function, and the reassignment of an immutable (`a -= 1`) is not an alteration of the value.
27572757
27582758
* Being aware of these nitpicks can save you hours of debugging effort in the long run.
27592759

0 commit comments

Comments
 (0)