On Mon, Feb 27, 2023 at 3:56 AM inhahe <inh...@gmail.com> wrote:

>
>
> On Mon, Feb 27, 2023 at 3:52 AM Roel Schroeven <r...@roelschroeven.net>
> wrote:
>
>> 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.
>>
>> --
>>
>>
> I'm not sure, but I think I remember this was actually a bug in the
> interpreter, and presumably they didn't fix it because they didn't want to
> break backward compatibility?
>
>
Maybe I'm thinking of a variable scope leak after list comprehensions.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to