Python
[python] 메서드 소스를 보고 싶을 때 (inspect 모듈 사용) / 바이트 코드 보기
브라이언7
2016. 8. 28. 00:38
# add() 의 도움말 보기
help(add)
# add()의 파이썬 소스를 보고 싶을 때
import inspect
inspect.getsource(add)
# 바이트 코드 보기
import dis
dis.dis(add)
len((1,))
=> 1
()만 있으면 길이가 0인 tuple
(1) 은 int type. ()는 우선 연산자로 작동한다.
(1,) 은 길이가 1인 tuple
v=()
print(type(v)) # <class 'tuple'>
print(len(v)) # 0
v=1
print(type(v)) # <class 'int'>
# print(len(v))
# TypeError: object of type 'int' has no len()
v=(1,)
print(type(v)) # <class 'tuple'>
print(len(v)) # 1
함수 안에서 static 변수를 설정하려면
http://hashcode.co.kr/questions/528/함수-안에서-static-변수를-설정하려면