On 02/21/2014 11:04 AM, Yury Selivanov wrote: > On 2/20/2014, 10:15 PM, Chris Angelico wrote: >> >> * list.pop() - no way to return a default > > We can fix that in 3.5. How many are you going to "fix"? How are you going to "fix" the routines you don't control? >> * seq[index] - no way to handle a bounds error > > We can add 'list.get(index, default)' method, similar to > 'Mapping.get'. It's far more easier than introducing new > syntax. When I have to keep writing the same code over and over and aver again, I find a better way to do the job. In this case, an exception expression does quite nicely. > I also searched how many 'except IndexError' are in > the standard library code. Around 60. That's a rather > low number, that can justify adding 'list.get' but not > advocate a new syntax. And roughly 200 of KeyError, another couple hundred of ValueError... This is not just about better handling of [missing] default values, but of better exception handling. This PEP adds the ability to use a scalpel instead of a sledge hammer. -- ~Ethan~
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4