ROKO

[Python] Python Enhancement Proposal(PEP) 본문

Computer Science/Programming Language

[Python] Python Enhancement Proposal(PEP)

RO_KO 2023. 3. 2. 17:25
728x90

ML,DL을 tensorflow, pytorch로 하다보니 python을 이용해 코드를 주로 짜게 되었다. 이 과정에서 python 언어 자체에 대한 이해도가 필요하다고 느껴 파이썬을 프로그래밍 언어로써 공부하고 파이썬을 이용해 다양한 알고리즘 문제를 풀며 구현 능력을 향상 시키려고 한다.

 

[참고자료]

https://www.python.org

 

Welcome to Python.org

The official home of the Python Programming Language

www.python.org

https://docs.python.org/ko/3/tutorial/index.html

 

The Python Tutorial

Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python’s elegant syntax an...

docs.python.org

간략한 역사를 알아보기 좋은 요약집

https://namu.wiki/w/Python

 

Python - 나무위키

구글 코랩이나 jupyter notebook을 이용한 로컬 및 네트워크 GPU 기반 병렬 연산에 용이한 것도 큰 장점이다. 머신러닝에서 파이썬이 대세가 된 주요 원인이기도 하다. Python은 프로그래머가 곧 자기가

namu.wiki

 

 시작하기에 앞서 PEP에 대한 것을 알아볼텐데, python은 네덜란드의 프로그래머 귀도 반 로섬을 중심으로 많은 사람들이 의논하며 만들어낸 언어이다. 그 과정에서 Python Software Foundation(PSF)에서 python 언어를 개발하며 의논사항이나 개선점들을 PEP로 문서화 하였다. 

PEP 20 The Zen of Python

REPL (Read Eval Print Loop) 환경 기반

import this

위 코드를 실행하면 PEP20에 관련된 문서가 출력된다.

더보기

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!

PEP 8 Style Guide for Python Code

# Correct:
x = 1
y = 2
long_variable = 3

# Wrong:
x             = 1
y             = 2
long_variable = 3

해당 코드는 동작은 똑같이 하지만 프로그래머의 코딩 스타일을 반영한다. 프로그램이 커질수록 협업을 하는 분야에서 각자의 개성은 작업의 효율을 낮추게 된다. 따라서 특정한 규율에 따라 코딩을 하도록 정리해 놓은 것이 PEP 8이다.

728x90
Comments