3 ms·
Yeah, I was pretty sure that was the case but just to be certain: >>> from dis import dis >>> dis(greet) 4 0 LOAD_GLOBAL 0
by CraigJPerry 4y ago
Yeah, I was pretty sure that was the case but just to be certain:
>>> from dis import dis
>>> dis(greet)
4 0 LOAD_GLOBAL 0 (print)
2 LOAD_CONST 1 ('Hello ')
4 LOAD_GLOBAL 1 (name)
6 BINARY_ADD
8 CALL_FUNCTION 1
10 POP_TOP
12 LOAD_CONST 0 (None)
14 RETURN_VALUE
>>> dis(greet1.greet)
4 0 LOAD_GLOBAL 0 (print)
2 LOAD_CONST 1 ('Hello ')
4 LOAD_GLOBAL 1 (name)
6 BINARY_ADD
8 CALL_FUNCTION 1
10 POP_TOP
12 LOAD_CONST 0 (None)
14 RETURN_VALUE
- TekMol 4y agoWow! So with this we can skip the class definition, having "self" as the first parameter of every function and prefixing all class variables with "self". That leads to so much cleaner code!