<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>saitodevel01</author_name>
  <author_url>https://blog.hatena.ne.jp/saitodevel01/</author_url>
  <blog_title>saito’s blog</blog_title>
  <blog_url>https://saitodevel01.hatenadiary.org/</blog_url>
  <categories>
    <anon>Python</anon>
    <anon>言語ネタ</anon>
    <anon>Ruby</anon>
  </categories>
  <description>僕が普段使用するPythonとRubyの変数のスコープについてまとめてみました。 Python 1. if文やfor文などの制御構造はスコープを作らない。 次のプログラムでは、if文の内側と外側のスコープは共通なので、if文内でaが上書きされてa=1が出力されます。 a = 0 if True: a = 1 print &quot;a = %d&quot; % a # a = 1 2. 関数定義とクラス定義では新しいスコープが作られる。関数定義やクラス定義では新しいスコープが作られるので、関数定義の内側と外側で同名の変数が存在しても、両者は区別されます。 次のプログラムでは、関数foo内で変数aに代入を行っていま…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fsaitodevel01.hatenadiary.org%2Fentry%2F20101205%2F1291582273&quot; title=&quot;PythonとRubyの変数のスコープのまとめ - saito’s 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>2010-12-05 05:51:13</published>
  <title>PythonとRubyの変数のスコープのまとめ</title>
  <type>rich</type>
  <url>https://saitodevel01.hatenadiary.org/entry/20101205/1291582273</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
