Indexable get method. [1,2,3].get(4) # None

Can’t provide enough examples because of 2 links limitation. There’s 5 links in the original discussion. And I can find few dozens more with google queries like ‘safe get method for list python’.

Also I found that this idea was already posted here in 2023 Add safe `.get` method to List - #3 by NoahTheDuke And even discussion with answer from Guido van Rossum Mailman 3 What about having a .get(index, default) method for arrays like we have for dicts? - Python-ideas - python.org

So maybe it’s time to close this topic

1 Like