Last active
August 14, 2017 11:33
-
-
Save vladvelici/7720261818b1704acd7d09bdcb49ff62 to your computer and use it in GitHub Desktop.
Gist for the elif Quora answer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 0 LOAD_CONST 0 (5) | |
2 STORE_NAME 0 (x) | |
2 4 LOAD_NAME 0 (x) | |
6 LOAD_CONST 0 (5) | |
8 COMPARE_OP 0 (<) | |
10 POP_JUMP_IF_FALSE 22 | |
3 12 LOAD_NAME 1 (print) | |
14 LOAD_CONST 1 ('x less than 5') | |
16 CALL_FUNCTION 1 | |
18 POP_TOP | |
20 JUMP_FORWARD 26 (to 48) | |
4 >> 22 LOAD_NAME 0 (x) | |
24 LOAD_CONST 2 (10) | |
26 COMPARE_OP 0 (<) | |
28 POP_JUMP_IF_FALSE 40 | |
5 30 LOAD_NAME 1 (print) | |
32 LOAD_CONST 3 ('x less than 10') | |
34 CALL_FUNCTION 1 | |
36 POP_TOP | |
38 JUMP_FORWARD 8 (to 48) | |
7 >> 40 LOAD_NAME 1 (print) | |
42 LOAD_CONST 4 ('x bigger or equal to 10') | |
44 CALL_FUNCTION 1 | |
46 POP_TOP | |
>> 48 LOAD_CONST 5 (None) | |
50 RETURN_VALUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = 5 | |
if x < 5: | |
print("x less than 5") | |
elif x < 10: | |
print("x less than 10") | |
else: | |
print("x bigger or equal to 10") | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
python3 -m dis noelif.py > noelif.bytecode | |
python3 -m dis elif.py > elif.bytecode | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 0 LOAD_CONST 0 (5) | |
2 STORE_NAME 0 (x) | |
2 4 LOAD_NAME 0 (x) | |
6 LOAD_CONST 0 (5) | |
8 COMPARE_OP 0 (<) | |
10 POP_JUMP_IF_FALSE 22 | |
3 12 LOAD_NAME 1 (print) | |
14 LOAD_CONST 1 ('x less than 5') | |
16 CALL_FUNCTION 1 | |
18 POP_TOP | |
20 JUMP_FORWARD 26 (to 48) | |
5 >> 22 LOAD_NAME 0 (x) | |
24 LOAD_CONST 2 (10) | |
26 COMPARE_OP 0 (<) | |
28 POP_JUMP_IF_FALSE 40 | |
6 30 LOAD_NAME 1 (print) | |
32 LOAD_CONST 3 ('x less than 10') | |
34 CALL_FUNCTION 1 | |
36 POP_TOP | |
38 JUMP_FORWARD 8 (to 48) | |
8 >> 40 LOAD_NAME 1 (print) | |
42 LOAD_CONST 4 ('x bigger or equal to 10') | |
44 CALL_FUNCTION 1 | |
46 POP_TOP | |
>> 48 LOAD_CONST 5 (None) | |
50 RETURN_VALUE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = 5 | |
if x < 5: | |
print("x less than 5") | |
else: | |
if x < 10: | |
print("x less than 10") | |
else: | |
print("x bigger or equal to 10") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment