Hello,
On Sun, 29 Nov 2020 22:33:28 +0200
Serhiy Storchaka <[email protected]> wrote:
> 29.11.20 18:27, Paul Sokolovsky пише:
> > Here's example of it in action:
> >
> > $ cat example_for1.py
> > def fun():
> > x = 123
> > for x in range(5):
> > print(x)
> > print("old x:", x)
> >
> > fun()
>
>
> I am strong -1.
>
> 1. It will break existing code. Including a lot of code written by me.
I see, you can't really post anything without including 10-20KB of
previous discussion history. Linking to it doesn't work either. So
let's go over it again:
1. You are not supposed to be using this in "code written by you".
2. This is a demonstration that adding block-level scope to Python is
easy enough, nothing else.
3. If this ever be implemented "in production", it will be wrapped in
dedicated syntax like "for let" or "for const".
> 2. Shadowing local variables considered bad practice in other
> programming languages, and even forbidden is some of them. So why
> implement a feature considered harmful?
"By whom?"
Computational theory doesn't care about superstitions. Neither it
really cares about names (humans do). It only cares about where scope
for a particular binding starts and ends:
def fun1():
x = 1
def fun2():
x = 2 # Horror! x is shadowed!
--
Best regards,
Paul mailto:[email protected]
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/KP6TJDFFWIS45TRALURWQXT2RY4HQW7N/
Code of Conduct: http://python.org/psf/codeofconduct/