I am a beginner in Python and also on GitHub - my apologies in advance if this is a dumb suggestion or made inappropriately...
In the Python tutorial section 5.5 on dictionaries it says: "It is an error to extract a value using a non-existent key."
However, a quick test shows that an error is not generated. Rather, the value None is returned. Should the documentation be amended to that effect?
Python 3.12.2 (tags/v3.12.2:6abddd9, Feb 6 2024, 21:26:36) [MSC v.1937 64 bit (AMD64)] on win32
>>> my_dict = {'a': 1, 'b': 2, 'c': 3}
>>> value = my_dict.get('d')
>>> print(value)
None
Documentation
I am a beginner in Python and also on GitHub - my apologies in advance if this is a dumb suggestion or made inappropriately...
In the Python tutorial section 5.5 on dictionaries it says: "It is an error to extract a value using a non-existent key."
However, a quick test shows that an error is not generated. Rather, the value None is returned. Should the documentation be amended to that effect?
Thanks,
Dan
Linked PRs
dict.getin the data structures tutorial (GH-139643) #139655dict.getin the data structures tutorial (GH-139643) #139656