<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>yoshitaku_jp</author_name>
  <author_url>https://blog.hatena.ne.jp/yoshitaku_jp/</author_url>
  <blog_title>よしたく blog</blog_title>
  <blog_url>https://yoshitaku-jp.hatenablog.com/</blog_url>
  <categories>
    <anon>Python</anon>
  </categories>
  <description>自分が知らなかったのでメモ 関数のデフォルト引数にリストを設定した時、デフォルト引数のリストの内容は再度実行したタイミングでも前の内容を保持します。 def sample(a, b=[]): b.append(a) return b print(sample('test')) ['test'] print(sample('test')) ['test', 'test'] 公式ドキュメントを読む 公式ドキュメントを当たると、次のように書いてあります。 デフォルト引数値は関数定義が実行されるときに左から右へ評価されます。 これは、デフォルト引数の式は関数が定義されるときにただ一度だけ評価され、同じ…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fyoshitaku-jp.hatenablog.com%2Fentry%2F2020%2F07%2F19%2F070000&quot; title=&quot;【Python】デフォルト引数にリストを使うときの注意点 - よしたく blog&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>2020-07-19 07:00:00</published>
  <title>【Python】デフォルト引数にリストを使うときの注意点</title>
  <type>rich</type>
  <url>https://yoshitaku-jp.hatenablog.com/entry/2020/07/19/070000</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
