On Tue, May 5, 2020 at 10:08 PM Steven D'Aprano <[email protected]> wrote:
>
> On Tue, May 05, 2020 at 04:05:20AM -0000, Brandt Bucher wrote:
> > It's a fairly common idiom to just collect `locals()` on the first
> > line of a function or method with lots of arguments
>
> Indeed, but it's that requirement that it must be precisely on the first
> executable statement of the function that makes it fragile.
>
Particularly sneaky is this problem:
def __init__(self, x, y, z, a, b, c):
stuff = locals()
spam = "ham"
# what's in stuff now?
Does stuff["stuff"] have a value? What about stuff["spam"] ? You can't be sure.
ChrisA
_______________________________________________
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/ZROJCADGLY4HOARP4K7OH3JJEORWNZC4/
Code of Conduct: http://python.org/psf/codeofconduct/