Use of a variable in parent loop

Chris Angelico rosuav at gmail.com
Sun Sep 27 18:55:54 EDT 2020


On Sun, Sep 27, 2020 at 9:41 PM Manfred Lotz <ml_news at posteo.de> wrote:
>
> On Sun, 27 Sep 2020 15:18:44 +0800
> Stephane Tougard <stephane at sdf.org> wrote:
>
> > 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.
> >
> >
>
> It is very good that you try out things. Nevertheless, it is also good
> to read. In other words the combination of reading and trying out
> things is the best way to make progress.
>
> Here some pointers
>
> pass
>
> - http://localhost:2015/tutorial/controlflow.html#pass-statements
>

Looks like you're linking to a local copy of the documentation. Here's
the same page from the official docs:

https://docs.python.org/3/tutorial/controlflow.html#pass-statements

(It'll be the same information, modulo version differences, but this
one should be available everywhere.)

ChrisA


More information about the Python-list mailing list