Created
December 4, 2019 04:01
-
-
Save junetech/e60c26c8b879c982751f98829830b802 to your computer and use it in GitHub Desktop.
Python error raising & args passing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for j in range(2): | |
try: | |
for i in range(10): | |
print(i) | |
if i == 3: | |
raise StopIteration | |
except: | |
print("raised successfully") | |
continue | |
def u_func(i: int): | |
if i == 0: | |
raise ValueError(5555) | |
else: | |
print(i) | |
i_list = [1, 0] | |
for i in i_list: | |
try: | |
u_func(i) | |
except ValueError as err: | |
print(type(err.args)) | |
print(err.args[0]) | |
print(type(err.args[0])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment