인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

Inflearn Community Q&A

irongalactico0001657's profile image
irongalactico0001657

asked

Python for Everyone: Learn Essential Syntax Feat. Open Source Package Distribution (Inflearn Original)

Context Manager Annotation

에러발생합니다2

Written on

·

235

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!')
python

Answer 1

0

niceman님의 프로필 이미지
niceman
Instructor

안녕하세요.

아래 답글 달았습니다.

irongalactico0001657's profile image
irongalactico0001657

asked

Ask a question