본문 바로가기
파이썬

파이썬 Python 2의 유형 힌트

by º기록 2020. 11. 9.
반응형


 

해결 방법

 


일부 도구는 Python 2.7과 호환되어야하는 코드에서 유형 주석을 지원할 수 있습니다. 이를 위해이 PEP에는 함수 주석이 # 유형 : 주석에 배치되는 제안 된 (필수는 아님) 확장이 있습니다. 이러한 주석은 함수 헤더 바로 뒤에 (독 스트링 앞) 배치해야합니다. 예 : 다음 Python 3 코드 :

def embezzle(self, account: str, funds: int = 1000000, *fake_receipts: str) -> None:
    """Embezzle funds from account using fake receipts."""
    <code goes here>

다음과 같습니다.

def embezzle(self, account, funds=1000000, *fake_receipts):
    # type: (str, int, *str) -> None
    """Embezzle funds from account using fake receipts."""
    <code goes here>


 

참조 페이지 https://stackoverflow.com/questions/35230635

 

 

반응형

댓글