{"type":"rich","height":"190","author_name":"derwind","author_url":"https://blog.hatena.ne.jp/derwind/","blog_url":"https://randommemory.hatenablog.com/","provider_name":"Hatena Blog","image_url":null,"width":"100%","blog_title":"\u3089\u3093\u3060\u3080\u306a\u8a18\u61b6","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Frandommemory.hatenablog.com%2Fentry%2F2016%2F05%2F06%2F024238\" title=\"\u304f\u308d\u30fc\u3058\u3083\uff1f - \u3089\u3093\u3060\u3080\u306a\u8a18\u61b6\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","description":"\u3055\u3066\u3001closure\u3044\u3063\u3068\u304f\u304b\u3068\u3001 def hoge(): val = 2 def fuga(): val += 1 for i in range(3): fuga() print(\"%d\" % val) \u3059\u308b\u304b\u30fc\u3068\u601d\u3063\u305f\u3089\u3001UnboundLocalError \u3068\u304b\u3044\u3044\u304a\u308b\u3002\u304a\u3043\u304a\u3043\u3001\u305b\u306b\u3087\u308a\uff5e\u305f\u3001\u5197\u8ac7\u304d\u3064\u3044\u3088\u30fc\u3002\u3063\u3066python2.x\u306f\u3053\u3093\u306a\u3082\u3093\u3060\u3068\u3063\uff01\uff1f def hoge(): val = [2] def fuga(): val[0] += 1 for i in range(3): fuga() print(\"%d\" % val[0]) \u3068\u304b\u3059\u308b\u3093\u3060\u3068\u3002\u6ce3\u304d\u305f\u304f\u306a\u308b\u306a\u3053\u308c\u3002 python3\u2026","url":"https://randommemory.hatenablog.com/entry/2016/05/06/024238","published":"2016-05-06 02:42:38","provider_url":"https://hatena.blog","version":"1.0","categories":["Python"],"title":"\u304f\u308d\u30fc\u3058\u3083\uff1f"}