違いは何だraise
とraise from
Pythonでは?
try:
raise ValueError
except Exception as e:
raise IndexError
これは
Traceback (most recent call last):
File "tmp.py", line 2, in <module>
raise ValueError
ValueError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "tmp.py", line 4, in <module>
raise IndexError
IndexError
そして
try:
raise ValueError
except Exception as e:
raise IndexError from e
これは
Traceback (most recent call last):
File "tmp.py", line 2, in <module>
raise ValueError
ValueError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "tmp.py", line 4, in <module>
raise IndexError from e
IndexError
raise IndexError from None
、と言ってください。
raise IndexError from False
上げTypeError
、ありませんIndexError
。私の日を作りました。