1. 한줄의 문자길이 < 80
2. 변수, 함수는 lowercase_underscore
3. 클래스는 CapitalizedWord
4. 상수는 ALL_CAPS
5. if len(somelist)==0
대신 if not somelist
6. map함수 사용. map(function, something_iterable←배열, 리스트)
* reduce(누적합), filter(조건검색), counter, set(중복제거)
7. 리스트/스트링에서 unique요소뽑기. set(변수명)
8. 한줄에 import 한개
List: [expr for x in iterable]
/ [expr for x in iterable if condition]
Dictionary: {key: value for x in iterable if condition}
for index, row in data.iterrows():
print(row['name'], row['age'])
~$ # f-strings (python 3.6~)
~$ name = 'Gildong Hong'; company='Ship com.'
~$ print(f"I am {name}, I belongs to {company})
if m in [1,3,5,7]: equal to if m==1 or m==3 or m==5 or m==7:
$nohup python *.py &
(터미널을 종료하더라도 백그라운드에서 계속 실행)
- $ps u / x
: 사용자 실행 프로세스 / 모든 프로세스
- $kill pid
: 프로세스 종료하기
function_name = lambda argument: expression
* square = lambda x: x^2
=> square(2)
=> 4
if __name__ == "__main__":
# Self-testing code goes here.
else:
# This will be executed in case the source has been imported as a module.