i always cringe when I find myself reaching for "nonlocal" in python. it looks gross, it feels gross, but it works, sooo... :-/
=> More informations about this toot | More toots from pamelafox@fosstodon.org
@pamelafox I’m new to learning python, so i had to look it up.
Now that I think I understand the concept, I agree.
Question: Instead of using nonlocal — why not pass the value as a argument through the necessary functions? At least it’s clear about the flow of data.
=> More informations about this toot | More toots from awoodsnet@phpc.social
@awoodsnet good q - In this case, I'm not the one calling the functions, it's a mocked function for a test. So I know when I get called, but I dont have the flexibility to alter the arguments. The other thing I could do is to make a dict and mutate a key in it, and that'd avoid the need for nonlocal.
=> More informations about this toot | More toots from pamelafox@fosstodon.org This content has been proxied by September (ba2dc).Proxy Information
text/gemini