Philosophy of Python

Calvin Park·2022년 7월 15일
0

파이썬에는 파이썬다운 방식(Pythonic Way)라는 고유한 철학이 있다. 이미 파이썬은 누구나 사용하는 거대하고 범용적인 언어가 되었지만, 여전히 파이썬다운 방식이라는 철학은 기저에 깔려 있으며, 새로운 모듈을 작성하는 개발자들이 한 번쯤은 되새기는 철학이기도 하다. 파이썬에서는 언어 차원에서 Zen of Python이라는 이름으로 이러한 철학을 제공한다. 6장 '문장열 조작'에서 살펴보게 될 소팅 알고리즘인 Timsort를 만든 Tim Peters가 정의한 내용이며 다음과 같이
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!

아름다움이 추함보다 낫다
명시적인 것이 암시적인 것보다 낫다
단순함이 복잡함보다 낫다
복잡함이 꼬인 것보다 낫다
수평이 계층보다 낫다
여유로운 것이 밀집된 것보다 낫다
가독성이 중요하다
틀별한 경우라는 것은 규칙을 어겨야 할 정도로 특별한 것이 아니다
비록 실용성이 순수성에 우선하지만
에러 앞에서는 절대 침묵하지 말라
명시적으로 에러를 감추려는게 아니라면
모호함을 앞에 두고 이를 유추하겠다는 유혹을 버려라
문제를 풀어낼 -바람직하고도 유일하며- 명확한 방법이 존재할 것이다.

파이썬 알고리즘 인터뷰 中 에서...

profile
Personal Velog Note

0개의 댓글