diff options
| author | nsfisis <nsfisis@gmail.com> | 2023-03-12 15:12:10 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2023-03-12 15:12:10 +0900 |
| commit | de13d68cddef5bb321469bcffb868f27ddd5390e (patch) | |
| tree | 3183bb2bc8b2ad7d34b6953e6a248747239f0afa /public/posts/2021-10-02/python-unbound-local-error/index.html | |
| parent | 5b49e6bca39d7cd3b98db8b826dc597d9f758a26 (diff) | |
| download | blog.nsfisis.dev-de13d68cddef5bb321469bcffb868f27ddd5390e.tar.gz blog.nsfisis.dev-de13d68cddef5bb321469bcffb868f27ddd5390e.tar.zst blog.nsfisis.dev-de13d68cddef5bb321469bcffb868f27ddd5390e.zip | |
style: add .highlight class to pre tag
Diffstat (limited to 'public/posts/2021-10-02/python-unbound-local-error/index.html')
| -rw-r--r-- | public/posts/2021-10-02/python-unbound-local-error/index.html | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/public/posts/2021-10-02/python-unbound-local-error/index.html b/public/posts/2021-10-02/python-unbound-local-error/index.html index fa0b1db..27c2d05 100644 --- a/public/posts/2021-10-02/python-unbound-local-error/index.html +++ b/public/posts/2021-10-02/python-unbound-local-error/index.html @@ -60,7 +60,7 @@ Python でクロージャを作ろうと、次のようなコードを書いた。 </p> - <pre language="python" linenumbering="unnumbered"> + <pre class="highlight" language="python" linenumbering="unnumbered"> <code>def f(): x = 0 def g(): @@ -84,7 +84,7 @@ f()</code> local変数<code>x</code>が代入前に参照された、とある。これは、<code>f</code>の<code>x</code>を参照するのではなく、新しく別の変数を<code>g</code>内に作ってしまっているため。 前述のコードを宣言と代入を便宜上分けて書き直すと次のようになる。<code>var</code>を変数宣言のための構文として擬似的に利用している。 </p> - <pre language="python" linenumbering="unnumbered"> + <pre class="highlight" language="python" linenumbering="unnumbered"> <code># 注: var は正しい Python の文法ではない。上記参照のこと def f(): var x # f の local変数 'x' を宣言 @@ -101,7 +101,7 @@ g()</code> 当初の意図を表現するには、次のように書けばよい。 </p> - <pre language="python" linenumbering="unnumbered"> + <pre class="highlight" language="python" linenumbering="unnumbered"> <code>def f(): x = 0 def g(): |
