Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

No library in a language with exceptions as they're normally used would do that. Exceptions are for exceptional cases. You use the method that throws only if it is a programming error for it to throw; and you do not, as a general rule, catch exceptions. See eg Dictionary.TryGetValue in .net. Your argument is against a straw man, IMHO.


So are you saying python is not a sane language?

    >>> a = {}
    >>> a['foo']
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    KeyError: 'foo'


Python uses Exceptions for unexceptional cases, yes, like loop termination. It's one of the only languages to do it.


It is widely agreed that this behavior is a hack in Python. It is not a role model.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: