Search code examples
pythonexceptiontry-catch

In Python, why raise/except instead of throw/catch ? Any other language using this naming convention?


In Python, we use try/except to handle exceptions.

However, I have no knowledge of any other language using such naming convention.

On the other hand, I know that the following languages use try/catch and throw:

  • C#
  • Java
  • Javascript

A search of try except on Google gives, on first page, only Python and a Microsoft C/C++ extension.

Why have Python developers chosen raise/try-except instead of throw/try-catch like many other languages do?

In addition, does any other language use raise/try-except?


Solution

  • In python, we can make use of this statement by using multiple except statements under a try condition, hence this can become a good programming practice. Python was developed for an easy understand-ability of the code even by a person with no programming knowledge, this is to avoid unclear or confusing codes to understand for future review.