-
Notifications
You must be signed in to change notification settings - Fork 301
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
[Python] Python Dictionary remove_from_dict does not work with tuple as dictionary key. #3615
Comments
Del removes a referencefor a namespace. The reference needs to be there. I guess the reason is that the tuple is not present as a key int he dictionary. |
@andreaschrader I tried your solution, but it doesn't work
I am not exactly sure what you mean by that, but def remove_from_dict(di: dict[_K, Any], k: _K) -> bool:
if k in di:
del di[k]
return True
return False |
The problem here is that the |
Assume the following:
Getting values from key will work for both dictionary, but when i try to remove values by key it will throw an error for tuple as key.
I checked the transpiled code and saw that
my_dict.Remove((0,0))
gets transpiled to:remove_from_dict(my_dict, (0, 0))
.Then checking the fable_library source files we find:
I copied the dictionary creation code to a jupyter notebook and tested the
del
part ofremove_from_dict
and it turns out that it fails as soon as del is called with a tuple as key for the dictionaryAs Fable.Python is pretty "cutting edge" i will provide the f# source code without a REPL. It was transpiled using dotnet tool fable
4.6.0
@HLWeil
The text was updated successfully, but these errors were encountered: