<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>atsuoishimoto</author_name>
  <author_url>https://blog.hatena.ne.jp/atsuoishimoto/</author_url>
  <blog_title>atsuoishimoto's diary</blog_title>
  <blog_url>https://atsuoishimoto.hatenablog.com/</blog_url>
  <categories>
    <anon>Python</anon>
  </categories>
  <description>テスト等でデコレータのデコレート前の関数を保存する必要があるなら、こんなのはどうだろう？ import sys def tee(f): sys._getframe(1).f_locals['_raw_'+f.func_name] = f return f デコレートした関数オブジェクトから元の関数を取り出すのは難しいし、テスト対象のモジュールをインポートするときに一時的にデコレータを置き換える手では安定した動作は難しい。また、外部のモジュールを再利用することを考えると、デコレータ関数に手を入れるのは避けたい。というわけで思いついたのは上のデコレータだ。こんな感じで使う： def deco(f)…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fatsuoishimoto.hatenablog.com%2Fentry%2F20110402%2F1301727265&quot; title=&quot;デコレータの元関数を保存する - atsuoishimoto&amp;#39;s diary&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2011-04-02 15:54:25</published>
  <title>デコレータの元関数を保存する</title>
  <type>rich</type>
  <url>https://atsuoishimoto.hatenablog.com/entry/20110402/1301727265</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
