Open Dan-at-56 opened 5 months ago
I note that I do get an error if attempting to extract the value using "my_dict['d'], so the documentation is correct if it's referring only to this method of extracting a value.
The point of the .get method is to avoid the exception and possibly provide a non-default default.
@rhettinger or others. Should we add a qualifier here? How about mentioning dict.get and perhaps replace a redundant example with its use. Also, I notice that 11 methods are listed for lists and none for tuple, set, and dict. Add those for the rest?
How about mentioning dict.get and perhaps replace a redundant example with its use.
+1 The get()
method is in common use and beginners would be benefit from being introduced early.
Also, I notice that 11 methods are listed for lists and none for tuple, set, and dict. Add those for the rest?
I don't think so. The tutorial is an introduction and its easy to drown a reader in details. For dicts and sets, it is better to focus on the core operations than to explore all the methods.
Hi @rhettinger @terryjreedy I can look into this issue.
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