나의 코드는 반드시 누군가 유지보수 하게 되어있습니다.
상대방에 대한 배려심으로 클린 코드를 공부해야 합니다.
PYTHON의 클린 코드에 대해서 정리해 보겠습니다.
# 일반코드
user = get_user()
if user:
post = get_post()
if post:
commnet = get_comment()
---------------------------------------------------------------
# 가드클러즈
user = get_user()
user = user if user else None
post = get_post()
post = post if post else None
commnet = get_comment()
commnet = commnet if post else None
if not a:
a + 1
commnet = 'hello' if post else None
a = 'apple'
if a == 'apple':
return 'fruit'
elif a == 'carrot'
return 'vegitable'
else:
return None
--------------------------------
a = 'apple'
data = {
'apple' : 'fruit',
'carrot' : 'vegitable'
}
data.get(a, None)