this
The Zen of Python 이 나옴 *_*
>>> import this
The Zen of Python, by Tim Peters
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
dis
Disassembler for Python bytecode
구문의 stack을 보여준다.
>>> import dis
>>> dis.dis(lambda x, y, z: (x + y) * z)
1 0 LOAD_FAST 0 (x)
3 LOAD_FAST 1 (y)
6 BINARY_ADD
7 LOAD_FAST 2 (z)
10 BINARY_MULTIPLY
11 RETURN_VALUE
ast
Abstract Syntax Trees
식의 구문 트리를 보여준다.
>>> import ast
>>> ast.dump(ast.parse("(1 + 2) * 3"))
'Module(body=[Expr(value=BinOp(left=BinOp(left=Num(n=1), op=Add(), right=Num(n=2)), op=Mult(), right=Num(n=3)))])'
'Dev > Python' 카테고리의 다른 글
[Coursera] Programming for Everybody (Python) - 10. Tuples (0) | 2015.08.31 |
---|---|
[Coursera] Programming for Everybody (Python) - 9. Dictionaries (0) | 2015.08.31 |
[Coursera] Programming for Everybody (Python) - 8. Lists (0) | 2015.08.31 |
[Coursera] Programming for Everybody (Python) - 7. Files (0) | 2015.08.31 |
[Coursera] Programming for Everybody (Python) - 6. Strings (0) | 2015.08.31 |