Home 파이썬 다운 방식 파이썬 철학(Pythonic Way)
Post
Cancel

파이썬 다운 방식 파이썬 철학(Pythonic Way)

파이썬에는 파이썬다운 방식이라는 고유한 철학이 있습니다.

언어차원에서 Zen of Python이라는 이름으로 철학을 제공하는데 import this로 이를 볼 수 있습니다.

1
import this

this를 import하면 볼 수 있습니다.

img1 daumcdn

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!

아름다움이 추함보다 낫다
명시적인 것이 암시(묵시)적인 것보다 낫다
단순함이 복잡함보다 낫다
수평이 계층보다 낫다
여유로운 것이 밀집된 것보다 낫다
가독성은 중요하다
특별한 경우라는 것은 규칙을 어겨야 할 정도로 특별 한것이 아니다.
비록 실용성이 순수성에 우선하지만
에러 앞에서는 침묵하지 마라
명시적으로 에러를 감추려는게 아니라면,
모호함을 두고 이를 유추하겠다는 유혹을 버려라
문제를 풀어낼 -바람직하고도 유일하며- 명확한 방법이 존재할 것이다.
비록 당신이 네덜란드인이 아니라면 처음에는 그런 방법이 분명하지 않을 수도 있다.
지금 하는 것이 안하는 것보다 낫다.
지금 당장 하는 것보다 나은 것은 없다.
구현하는 것보다 설명하기 어렵다면 이는 좋지 않은 생각입니다.
구현하는 것보다 설명하기 쉽다면, 좋은 생각일 것이다.
네임스페이스는 경적을 울리는 좋은 아이디어 중 하나이다. 그런 아이디어들을 더 많이 해보자!

파이썬을 사용하면서 항상 되새겨야 할 내용입니다.

“문제를 풀어낼 바람직하고도 유일하며 명확한 방법이 존재할 것이다. 이것이 바로 파이썬 다운 방식일 것입니다.

This post is licensed under CC BY 4.0 by the author.

Comments powered by Disqus.

파이썬 나눈셈, 몫, divmod 연산자 의미와 사용방법

파이썬 리스트에서 2x2배열에서 얕은 복사가 일어나는 경우