강의

멘토링

로드맵

인프런 커뮤니티 질문&답변

carrilaiald KIM님의 프로필 이미지
carrilaiald KIM

작성한 질문수

모두를 위한 파이썬 : 필수 문법 배우기 Feat. 오픈소스 패키지 배포 (Inflearn Original)

Context Manager Annotation

에러발생합니다2

작성

·

239

0

#Context Manager and Contextlib, __enter__,__exit__ #Ex1 import time class ExcuteTimer(object): def __init__(self,msg): self._msg=msg def __enter__(self): self._start=time.monotonic() return self._start def __exit__(self,exc_type,exc_value,exc_traceback): if exc_type: print("Logging exception {}".format((exc_type,exc_value,exc_traceback))) else: print("{} {} s".format(self._msg, time.monotonic()-self._start)) return True with ExcuteTimer('Start! job') as v: print('Received start monotonic1:{}'.format(v)) for i in range(1000000): pass raise Exception('Raise! Exception!')

답변 1

0

좋은사람님의 프로필 이미지
좋은사람
지식공유자

안녕하세요.

아래 답글 달았습니다.

carrilaiald KIM님의 프로필 이미지
carrilaiald KIM

작성한 질문수

질문하기