Hello,

On Sun, 16 Jan 2022 17:31:48 +0200
Iyad Ahmed <iyadahmed...@gmail.com> wrote:

> Example use cases:
> 
>    - Loop variables and similar, it is sometimes more comfortable to
> scope it to the loop body only
>    - Not having to name variables var1, var2, var3, or makeup
> unnecessarily unique variable names, in some situations
> 
> 
> 
> In other languages the curly bracket is used, in Python round brackets
> might fit more in the syntax.
> 
> I don’t have much experience with the implementation of Python, so
> not sure if there’s a technical reason against such idea,
> feedback is very appreciated

There was an idea to introduce both mutable and immutable block-scoped
vars, e.g.:

if 1:
    # Immutable aka const
    const x = 1
# x is undefined here
if 1:
    # Mutable
    let x = 1
    x = 2
# x is undefined here

("const" and "let" pretty much match the behavior of similar keywords
in the modern JavaScript).


If you want to see a dialect of Python with block scoped vars (and only
block-scoped vars), there's Kuroko:
https://github.com/kuroko-lang/kuroko . Example of its source code:

https://github.com/kuroko-lang/kuroko/blob/master/test/day3.krk



-- 
Best regards,
 Paul                          mailto:pmis...@gmail.com
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/U5EYSHUNJL5XWGRW2M6LKMBSCT4YL7GY/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to