5 May
2020
5 May
'20
6:04 p.m.
On Tue, May 5, 2020 at 10:08 PM Steven D'Aprano
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