-
-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
setvar out = out or mydict idiom doesn't work with empty dict, maybe deepcopy() #1866
Comments
Another possibility is to just evaluate at call time That's probably easiest However there is still the possibility of aliasing a global there ... Like
|
I think, the possibility is good, very much needed actually, to keep and update an external state, by default, and be able to call the same proc to process with another mutable for particular runs. It's only the misleading " A well integrated |
FWIW JavaScript now has syntactic sugar for
Someone asked for |
Sorry
setvar out = out or mydict
has a bit of a pitfall -- whenout
is the empty dict.The
or
operator tests if a value is "falsey", and that includes empty containers --{} [] false null
This is a bit of an unfortunate interaction -- it's something Python also has. I actually tried to change what the
or
operator meant, but it causes other problems elsewhere in the language.So really the right thing for dicts is
rather than
Originally posted by @andychu in #1842 (comment)
The text was updated successfully, but these errors were encountered: