Use of a variable in parent loop

Stephane Tougard stephane at sdf.org
Sun Sep 27 03:18:44 EDT 2020


On 2020-09-27, 2QdxY4RzWzUUiLuE at potatochowder.com <2QdxY4RzWzUUiLuE at potatochowder.com> wrote:
> As ChrisA noted, Python almost always Just Works without declarations.
> If you find yourself with a lot of global and/or nonlocal statements,
> perhaps you're [still] thinking in another language.


I don't really agree with that, trying to use an undeclared
object/variable/whatever :

Python 3.7.7 (default, Aug 22 2020, 17:07:43) 
[GCC 7.4.0] on netbsd9
Type "help", "copyright", "credits" or "license" for more information.
>>> print(name)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  NameError: name 'name' is not defined
  >>> 

You can say it's not the "declaration" the issue, it's the "definition",
that's just a matter of vocabulary and it does not answer the question.

In many non declarative language, if I do print($var), it just prints
and undefined value with returning an error.




More information about the Python-list mailing list