반응형

/*********************************************************************************************************
-- Title : [py2.3.7] dir() 내장함수 및 패키지
-- Reference : itsdong.comg
-- Key word : 클래스 내장함수 패키지 class package

*********************************************************************************************************/

# ---------------------------------------
# -- 클래스 내부 함수 외부 사용
# ---------------------------------------

# -- modlue4.py

pi=3.141592

class math:
def aaa(self, r):
return pi*(r**2)

def sum(i,j):
return i+j

if __name__ == '__main__':
print(pi)
bb = math()
print(bb.aaa(10))
print(sum(pi, 10))

# -- command line에서 클래스 호출
>>> sys.path.append('...')
>>> sys.path

>>> import module4
>>> test = module4.math()
>>> test.aaa(4)
50.27072

>>> module4.pi
3.141592

>>> module.sum(module4.pi, 10)
13.1419199999999

# ---------------------------------------
# -- 내부 함수
# ---------------------------------------

# -- dir() : 객체에 정의된 식별자을 알려줌

>>> dir(module4)

>>> test=12
>>> dir()
['__buildints__', '__doc__', '__name__', '__package__', 'test']

# -- 패키지 : 여러가지의 모듈을 포함
# 단순하게 폴더로 생각, init.py 파일 포함






반응형

+ Recent posts