On 25Nov2020 22:07, Guido van Rossum <gu...@python.org> wrote: >Hmm... In the end I think the language design issue is with functions (and >how they capture variable references rather than values), and fixing it by >changing the for-loop is still just a band-aid, with other problems and >inconsistencies. Agreed that the fix 'x=x' essentially always works, and >that having to write 'for new x in ...' is no better, because you'd still >forget it. > >Maybe we should consider introducing a new kind of function that captures >values instead? That would be a much more principled fix.
I was thinking in my previous post (where such thought was off topic:-) that block scopes for Python should be as clear as in C, without using braces. What about something along the lines of: with expression as new x, y: ... x and y local to this suite ... ... also x and y cannot shadow existing names ... I wouldn't want to let any "as" support a "new", but the one on "with" introduces a suite which nicely delineates a block. Cheers, Cameron Simpson <c...@cskk.id.au> _______________________________________________ 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/SYYUXGMYEVNTV6IQC2DM6DWEJFXBMRDK/ Code of Conduct: http://python.org/psf/codeofconduct/