In Python any other class, custom exception can define a constructor and you can pass arguments

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

Me : He usually writes in Java.
Someone : How can you say that?
Me : ca

펌킨잼
Автор

With a try: except: block, you can save the exception object to a variable.

try:
# code here
except CustomException as exception:
print(exception)
# more code can go here

If you do this, it's best if the exception class has a repr method.

ethanchristensen
Автор

In python they are not called "constructors", they are called "initializers" or "__init__" in short.

רועיכהן-כתובתישנה
welcome to shbcf.ru