From a4a72de9af0d0a6d17944f847a4d5fed2b05d2a7 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 23 Feb 2022 15:31:50 +0900 Subject: change site domain to `blog.nsfisis.dev` --- docs/posts/python-unbound-local-error/index.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'docs/posts/python-unbound-local-error/index.html') diff --git a/docs/posts/python-unbound-local-error/index.html b/docs/posts/python-unbound-local-error/index.html index e3a142c..227164a 100644 --- a/docs/posts/python-unbound-local-error/index.html +++ b/docs/posts/python-unbound-local-error/index.html @@ -16,12 +16,12 @@ def f(): x = 0 def g(): x += 1 g() f() 関数 g から 関数 f のスコー # 注: var は正しい Python の文法ではない。上記参照のこと def f(): var x # f の local変数 'x' を宣言 x = 0 # x に 0 を代入 def g(): # f の内部関数 g を定義 var x # g の local変数 'x' を宣言 # たまたま f にも同じ名前の変数があるが、それとは別の変数 x += 1 # x に 1 を加算 (x = x + 1 の糖衣構文) # 加算する前の値を参照しようとするが、まだ代入されていないためエラー g() 当初の意図を表現するには、次のように書けばよい。"> - - - + + + - - + + @@ -79,7 +79,7 @@ def f(): x = 0 def g(): x += 1 g() f() 関数 g から 関数 f のスコー
@@ -131,13 +131,13 @@ f()
- + -- cgit v1.2.3-70-g09d2