From a84908b7e8a0e2423afd6b836eccf27a420270b4 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 20 Sep 2023 19:56:52 +0900 Subject: feat(blog/nuldoc): change content format from DocBook to NulDoc --- .../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/index.html') 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 105b946b..cb6efafb 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 @@ -73,7 +73,7 @@ Python でクロージャを作ろうと、次のようなコードを書いた。

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

-
# 注: var は正しい Python の文法ではない。上記参照のこと
+          
# 注: var は正しい Python の文法ではない。上記参照のこと
 def f():
   var x           #  f の local変数 'x' を宣言
   x = 0           #  x に 0 を代入
@@ -110,7 +110,7 @@ f()
当初の意図を表現するには、次のように書けばよい。

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