Laurens Van Houtven wrote:
I don't think David is arguing for the default behavior to change -- merely that you get a dict.get style default.
I know, but experience shows that the dict.get() default is very useful in practice. I'm skeptical that the proposed feature would -- or should -- be used often enough to justify complexifying the constructor signature of int et al. The big difference as I see it is that, very often, failing to find something in a dict is not an error, but an entirely normal occurrence. On the other hand, passing something that isn't a valid int representation to int() is most likely the result of a user entering something nonsensical. In that case, the principle that "errors should not pass silently" applies. What's worse, it could become an attractive nuisance, encouraging people to mask bad input rather than provide the user with appropriate feedback. -- Greg