+ 2
why no ' : ' in the end of raise exception statement?
4 Antworten
+ 1
Because you are confusing it with except. Raise just throws an exception, no need for a block afterwards.
+ 1
Conceptually, colons introduce a "group of statements" (offset by indentation) to execute related to the line with the colon. Raising an exception immediately *jumps away* from wherever you are, so a block makes no sense here.
+ 1
' : ' is used where you want a block of statements for that particular line
Or you can say that it is for indentation
0
raise is method to raising exception using type of exception and error you want to show when validation of data types.