it seems like a few weeks ago... but actually it was more like 30 years ago that i was programming in C, and
Roel Schroeven
roel at roelschroeven.net
Mon Feb 27 03:51:18 EST 2023
Op 26/02/2023 om 6:53 schreef Hen Hanna:
> > There are some similarities between Python and Lisp-family
> > languages, but really Python is its own thing.
>
>
> Scope (and extent ?) of variables is one reminder that Python is not Lisp
>
> for i in range(5): print( i )
> .........
> print( i )
>
> ideally, after the FOR loop is done, the (local) var i should also disappear.
> (this almost caused a bug for me)
I wouldn't say "i *should* also disappear". There is no big book of
programming language design with rules like that that all languages have
to follow. Different languages have different behavior. In some
languages, for/if/while statements introduce a new scope, in other
languages they don't. In Python, they don't. I won't say one is better
than the other; they're just different.
--
"Most of us, when all is said and done, like what we like and make up
reasons for it afterwards."
-- Soren F. Petersen
More information about the Python-list
mailing list