From 09b8483ed67d3b85e983ef86c34260081975e1cb Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 2 May 2025 06:47:07 +0900 Subject: fix(blog/nuldoc): remove unnecessary "language" attribute --- .../public/posts/2021-10-02/python-unbound-local-error/index.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'vhosts/blog/public/posts/2021-10-02/python-unbound-local-error') diff --git a/vhosts/blog/public/posts/2021-10-02/python-unbound-local-error/index.html b/vhosts/blog/public/posts/2021-10-02/python-unbound-local-error/index.html index db2da17c..c3d48b89 100644 --- a/vhosts/blog/public/posts/2021-10-02/python-unbound-local-error/index.html +++ b/vhosts/blog/public/posts/2021-10-02/python-unbound-local-error/index.html @@ -76,7 +76,7 @@

Python でクロージャを作ろうと、次のようなコードを書いた。

-
+
def f():
     x = 0
     def g():
@@ -96,7 +96,7 @@
           

local変数 x が代入前に参照された、とある。これは、fx を参照するのではなく、新しく別の変数を g 内に作ってしまっているため。 前述のコードを宣言と代入を便宜上分けて書き直すと次のようになる。var を変数宣言のための構文として擬似的に利用している。

-
+
# 注: var は正しい Python の文法ではない。上記参照のこと
 def f():
   var x           #  f の local変数 'x' を宣言
@@ -111,7 +111,7 @@
           

当初の意図を表現するには、次のように書けばよい。

-
+
def f():
     x = 0
     def g():
-- 
cgit v1.2.3-70-g09d2