Variable declaration reset: Difference between revisions

Content added Content deleted
(J: fix bad markup)
m (Python example)
Line 361: Line 361:


=={{header|Python}}==
=={{header|Python}}==
In Python, variables are supposed to be defined before they are used, but the undefined variable `prev` is still not equal to `curr` below, so the code runs nevertheless. Note that a Python code checker such as pyflakes will flag such code.
In Python, variables are supposed to be defined before they are used. The code does run, but note that a Python code checker such as pyflakes will flag such code with an error.
<lang python>
<lang python>
s = [1, 2, 2, 3, 4, 4, 5]
s = [1, 2, 2, 3, 4, 4, 5]