Home > Back-end >  In Python, why raise/exept instead of throw/catch ? Any other language using this naming convention?
In Python, why raise/exept instead of throw/catch ? Any other language using this naming convention?

Time:01-07

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, is there another language using raise/try-except ?

CodePudding user response:

All pascal language are also using try / except naming convention like Delphi & lazarus

CodePudding user response:

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.

  •  Tags:  
  • Related