O 25/09/20 ás 09:12, Serhiy Storchaka escribiu:
Did not the experience of C++ show that exceptions declaration was a bad
idea? In C++ it was optional and is abandoned now. Java developers still
suffer from necessary to declare all raised exception, or just declare
the most general exception class, that makes the feature useless.
Could you elaborate as to why it was bad in C++? I looked it up and see that
it was deprecated before I learned C++ so I never used it myself, so I'm
interested to hear what was wrong with it.
I do agree that the way Java does it is too cumbersome, but I'm not proposing that Python gets Java-like checked exceptions, so I don't think it's a good comparison.
This may be especially bad for Python where virtually every line of code
can raise arbitrary exception. KeybordInterrupt and MemoryError are most
common examples, but in rare cases which usually are not covered by
tests it can be also UnicodeError, NameError, AttributeError, TypeError,
BufferError, etc.
Agreed! This is why I think this feature would be useful to document _expected_ Exceptions. Something that already happens anyway (in actual documentation) but would be (IMO) far more useful if it were to happen in the code itself (much like type annotations).
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/OWYWMYFKDOLWNQX2R4P4LGUXJIZR3NSW/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to