<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>melpon</author_name>
  <author_url>https://blog.hatena.ne.jp/melpon/</author_url>
  <blog_title>melpon日記 - HaskellもC++もまともに扱えないへたれのページ</blog_title>
  <blog_url>https://melpon.hatenadiary.org/</blog_url>
  <categories>
    <anon>Python</anon>
  </categories>
  <description>この記事は Python Tips Advent Calendar 2012 ２０日目の記事です。 Python の関数にはデフォルト値が付けられます。 このデフォルト値は、その関数を呼び出したタイミングではなく、その関数を定義したタイミングで初期化されます。 &gt;&gt;&gt; def f(): ... print 'called f' ... return [] &gt;&gt;&gt; def bar(x = f()): # この bar 関数の定義で f() が呼ばれる ... x.append(1) ... return x called f &gt;&gt;&gt; bar() # この呼び出しのときには f() は呼ばれない …</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fmelpon.hatenadiary.org%2Fentry%2F20121220%2F1356002420&quot; title=&quot;関数のデフォルト値の初期化タイミング - melpon日記 - HaskellもC++もまともに扱えないへたれのページ&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>2012-12-20 20:20:20</published>
  <title>関数のデフォルト値の初期化タイミング</title>
  <type>rich</type>
  <url>https://melpon.hatenadiary.org/entry/20121220/1356002420</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
