Skip to content

Commit 426cb0c

Browse files
committed
Use consistent "Explanation" headings.
Changes headings with just "#### Explanation:" to "#### 💡 Explanation" Fixes satwikkansal#22
1 parent fe050b8 commit 426cb0c

File tree

1 file changed

+43
-43
lines changed

1 file changed

+43
-43
lines changed

README.md

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -24,71 +24,71 @@ So, here ya go...
2424
- [Usage](#usage)
2525
- [👀 Examples](#-examples)
2626
- [Skipping lines?](#skipping-lines)
27-
- [Explanation](#explanation)
27+
- [💡 Explanation](#-explanation)
2828
- [Well, something is fishy...](#well-something-is-fishy)
29-
- [Explanation](#explanation-1)
29+
- [💡 Explanation](#-explanation-1)
3030
- [Time for some hash brownies!](#time-for-some-hash-brownies)
31-
- [Explanation](#explanation-2)
31+
- [💡 Explanation](#-explanation-2)
3232
- [Evaluation time discrepancy](#evaluation-time-discrepancy)
33-
- [💡 Explanation](#-explanation)
33+
- [💡 Explanation](#-explanation-3)
3434
- [Modifying a dictionary while iterating over it](#modifying-a-dictionary-while-iterating-over-it)
35-
- [Explanation:](#explanation)
36-
- [Deleting a list item while iterating over it](#deleting-a-list-item-while-iterating-over-it)
3735
- [💡 Explanation:](#-explanation-1)
36+
- [Deleting a list item while iterating over it](#deleting-a-list-item-while-iterating-over-it)
37+
- [💡 Explanation:](#-explanation-2)
3838
- [Backslashes at the end of string](#backslashes-at-the-end-of-string)
39-
- [Explanation](#explanation-3)
39+
- [💡 Explanation](#-explanation-4)
4040
- [Let's make a giant string!](#lets-make-a-giant-string)
41-
- [Explanation](#explanation-4)
41+
- [💡 Explanation](#-explanation-5)
4242
- [String concatenation interpreter optimizations.](#string-concatenation-interpreter-optimizations)
43-
- [💡 Explanation:](#-explanation-2)
44-
- [Yes, it exists!](#yes-it-exists)
4543
- [💡 Explanation:](#-explanation-3)
46-
- [`is` is not what it is!](#is-is-not-what-it-is)
44+
- [Yes, it exists!](#yes-it-exists)
4745
- [💡 Explanation:](#-explanation-4)
46+
- [`is` is not what it is!](#is-is-not-what-it-is)
47+
- [💡 Explanation:](#-explanation-5)
4848
- [`is not ...` is different from `is (not ...)`](#is-not--is-different-from-is-not-)
49-
- [Explanation](#explanation-5)
49+
- [💡 Explanation](#-explanation-6)
5050
- [The function inside loop sticks to the same output](#the-function-inside-loop-sticks-to-the-same-output)
51-
- [Explanation](#explanation-6)
51+
- [💡 Explanation](#-explanation-7)
5252
- [Loop variables leaking out of local scope!](#loop-variables-leaking-out-of-local-scope)
53-
- [💡 Explanation:](#-explanation-5)
54-
- [A tic-tac-toe where X wins in the first attempt!](#a-tic-tac-toe-where-x-wins-in-the-first-attempt)
5553
- [💡 Explanation:](#-explanation-6)
56-
- [Beware of default mutable arguments!](#beware-of-default-mutable-arguments)
54+
- [A tic-tac-toe where X wins in the first attempt!](#a-tic-tac-toe-where-x-wins-in-the-first-attempt)
5755
- [💡 Explanation:](#-explanation-7)
58-
- [Same operands, different story!](#same-operands-different-story)
56+
- [Beware of default mutable arguments!](#beware-of-default-mutable-arguments)
5957
- [💡 Explanation:](#-explanation-8)
60-
- [Mutating the immutable!](#mutating-the-immutable)
58+
- [Same operands, different story!](#same-operands-different-story)
6159
- [💡 Explanation:](#-explanation-9)
62-
- [Using a variable not defined in scope](#using-a-variable-not-defined-in-scope)
60+
- [Mutating the immutable!](#mutating-the-immutable)
6361
- [💡 Explanation:](#-explanation-10)
64-
- [The disappearing variable from outer scope](#the-disappearing-variable-from-outer-scope)
62+
- [Using a variable not defined in scope](#using-a-variable-not-defined-in-scope)
6563
- [💡 Explanation:](#-explanation-11)
66-
- [Return return everywhere!](#return-return-everywhere)
64+
- [The disappearing variable from outer scope](#the-disappearing-variable-from-outer-scope)
6765
- [💡 Explanation:](#-explanation-12)
68-
- [When True is actually False](#when-true-is-actually-false)
66+
- [Return return everywhere!](#return-return-everywhere)
6967
- [💡 Explanation:](#-explanation-13)
70-
- [Be careful with chained operations](#be-careful-with-chained-operations)
68+
- [When True is actually False](#when-true-is-actually-false)
7169
- [💡 Explanation:](#-explanation-14)
70+
- [Be careful with chained operations](#be-careful-with-chained-operations)
71+
- [💡 Explanation:](#-explanation-15)
7272
- [Name resolution ignoring class scope](#name-resolution-ignoring-class-scope)
73-
- [💡 Explanation](#-explanation-1)
73+
- [💡 Explanation](#-explanation-8)
7474
- [From filled to None in one instruction...](#from-filled-to-none-in-one-instruction)
75-
- [💡 Explanation](#-explanation-2)
75+
- [💡 Explanation](#-explanation-9)
7676
- [Explicit typecast of strings](#explicit-typecast-of-strings)
77-
- [💡 Explanation:](#-explanation-15)
77+
- [💡 Explanation:](#-explanation-16)
7878
- [Class attributes and instance attributes](#class-attributes-and-instance-attributes)
79-
- [Explanation:](#explanation-1)
79+
- [💡 Explanation:](#-explanation-17)
8080
- [Catching the Exceptions!](#catching-the-exceptions)
81-
- [Explanation](#explanation-7)
81+
- [💡 Explanation](#-explanation-10)
8282
- [Midnight time doesn't exist?](#midnight-time-doesnt-exist)
83-
- [💡 Explanation:](#-explanation-16)
83+
- [💡 Explanation:](#-explanation-18)
8484
- [Counting the booleans](#counting-the-booleans)
85-
- [💡 Explanation:](#-explanation-17)
85+
- [💡 Explanation:](#-explanation-19)
8686
- [Needle in a Haystack](#needle-in-a-haystack)
87-
- [💡 Explanation:](#-explanation-18)
87+
- [💡 Explanation:](#-explanation-20)
8888
- [Loop variable resilient to changes](#loop-variable-resilient-to-changes)
89-
- [💡 Explanation:](#-explanation-19)
89+
- [💡 Explanation:](#-explanation-21)
9090
- [Let's see if you can guess this?](#lets-see-if-you-can-guess-this)
91-
- [💡 Explanation:](#-explanation-20)
91+
- [💡 Explanation:](#-explanation-22)
9292
- [Minor Ones](#minor-ones)
9393
- [TODO: Hell of an example!](#todo-hell-of-an-example)
9494
- [Contributing](#contributing)
@@ -166,7 +166,7 @@ Wut?
166166

167167
**Note:** The easiest way to reproduce this is to simply copy the statements from the above snippet and paste them into your file/shell.
168168

169-
#### Explanation
169+
#### 💡 Explanation
170170

171171
Some Unicode characters look identical to ASCII ones, but are considered distinct by the interpreter.
172172

@@ -203,7 +203,7 @@ Shouldn't that be 100?
203203

204204
**Note:** If you're not able to reproduce this, try running the file [mixed_tabs_and_spaces.py](/mixed_tabs_and_spaces.py) via the shell.
205205

206-
#### Explanation
206+
#### 💡 Explanation
207207

208208
* **Don't mix tabs and spaces!** The character just preceding return is a "tab", and the code is indented by multiple of "4 spaces" elsewhere in the example.
209209
* This is how Python handles tabs:
@@ -239,7 +239,7 @@ some_dict[5] = "Python"
239239

240240
"Python" destroyed the existence of "JavaScript"?
241241

242-
#### Explanation
242+
#### 💡 Explanation
243243

244244
* `5` (an `int` type) is implicitly converted to `5.0` (a `float` type) before calculating the hash in Python.
245245
```py
@@ -297,7 +297,7 @@ for i in x:
297297

298298
Yes, it runs for exactly **eight** times and stops.
299299

300-
#### Explanation:
300+
#### 💡 Explanation:
301301

302302
* Iteration over a dictionary that you edit at the same time is not supported.
303303
* It runs eight times because that's the point at which the dictionary resizes to hold more keys (we have eight deletion entries, so a resize is needed). This is actually an implementation detail.
@@ -379,7 +379,7 @@ Can you guess why the output is `[2, 4]`?
379379
SyntaxError: EOL while scanning string literal
380380
```
381381

382-
#### Explanation
382+
#### 💡 Explanation
383383

384384
- In a raw string literal, as indicated by the prefix `r`, the backslash doesn't have the special meaning.
385385
- What the interpreter actually does, though, is simply change the behavior of backslashes, so they pass themselves and the following character through. That's why backslashes don't work at the end of a raw string.
@@ -427,7 +427,7 @@ def convert_list_to_string(l, iters):
427427
10000 loops, best of 3: 75.3 µs per loop
428428
```
429429

430-
#### Explanation
430+
#### 💡 Explanation
431431
- You can read more about [timeit](https://docs.python.org/3/library/timeit.html) from here. It is generally used to measure the execution time of snippets.
432432
- Don't use `+` for generating long strings — In Python, `str` is immutable, so the left and right strings have to be copied into the new string for every pair of concatenations. If you concatenate four strings of length 10, you'll be copying (10+10) + ((10+10)+10) + (((10+10)+10)+10) = 90 characters instead of just 40 characters. Things get quadratically worse as the number and size of the string increases.
433433
- Therefore, it's advised to use `.format.` or `%` syntax (however, they are slightly slower than `+` for short strings).
@@ -597,7 +597,7 @@ True
597597
False
598598
```
599599

600-
#### Explanation
600+
#### 💡 Explanation
601601

602602
- `is not` is a single binary operator, and has behavior different than using `is` and `not` separated.
603603
- `is not` evaluates to `False` if the variables on either side of the operator point to the same object and `True` otherwise.
@@ -635,7 +635,7 @@ Even when the values of `x` were different in every iteration prior to appending
635635
[512, 512, 512, 512, 512, 512, 512, 512, 512, 512]
636636
```
637637

638-
#### Explanation
638+
#### 💡 Explanation
639639

640640
- When defining a function inside a loop that uses the loop variable in its body, the loop function's closure is bound to the variable, not its value. So all of the functions use the latest value assigned to the variable for computation.
641641

@@ -1267,7 +1267,7 @@ True
12671267
```
12681268

12691269

1270-
#### Explanation:
1270+
#### 💡 Explanation:
12711271

12721272
* Class variables and variables in class instances are internally handled as dictionaries of a class object. If a variable name is not found in the dictionary of the current class, the parent classes are searched for it.
12731273
* The `+=` operator modifies the mutable object in-place without creating a new object. So changing the attribute of one instance affects the other instances and the class attribute as well.
@@ -1306,7 +1306,7 @@ ValueError: list.remove(x): x not in list
13061306
SyntaxError: invalid syntax
13071307
```
13081308

1309-
#### Explanation
1309+
#### 💡 Explanation
13101310

13111311
* To add multiple Exceptions to the except clause, you need to pass them as parenthesized tuple as the first argument. The second argument is an optional name, which when supplied will bind the Exception instance that has been raised. Example,
13121312
```py

0 commit comments

Comments
 (0)