
エントリーの編集

エントリーの編集は全ユーザーに共通の機能です。
必ずガイドラインを一読の上ご利用ください。
contextlib.ContextDecorator - Qiita
記事へのコメント0件
- 注目コメント
- 新着コメント
このエントリーにコメントしてみましょう。
注目コメント算出アルゴリズムの一部にLINEヤフー株式会社の「建設的コメント順位付けモデルAPI」を使用しています

- バナー広告なし
- ミュート機能あり
- ダークモード搭載
関連記事
contextlib.ContextDecorator - Qiita
import contextlib # @contextlib.contextmanager # def tag(name): # print('<{}>'.format(name)) # yi... import contextlib # @contextlib.contextmanager # def tag(name): # print('<{}>'.format(name)) # yield # print('</{}>'.format(name)) class tag(contextlib.ContextDecorator): def __init__(self, name): self.name = name self.start_tag = '<{}>'.format(name) self.end_tag = '</{}>'.format(name) def __enter__(self): print(self.start_tag) def __exit__(self, exc_type, exc_val, exc_tb): print(exc_type) print(e