- 1

Can you raise the statement outside the exception block ?? [Python]

This is a question in the exception handling section of learn python. I feel the answer to this question is ' no '. But the correct answer is given as ' yes '. I feel the answer should be ' no ' because, ' raise ' keyword cannot be used outside ' except ' block. please feel free to correct me if I am wrong. but if I am correct, please change it in the learn python tutorial module exception handling and files. Because lot of learners will be affected. with regards George J Padayatti

10th Jul 2018, 8:08 AM
Darkchylde
3 odpowiedzi
+ 7
https://www.quora.com/Can-we-use-a-raise-statement-outside-an-except-block-in-the-JUMP_LINK__&&__Python__&&__JUMP_LINK-language I'm not a Pythonist :) but I think that it clarifies it for you. The answer is 'YES'.
10th Jul 2018, 8:57 AM
Dev
Dev - avatar
+ 7
George J Padayatty Unsurprisingly, that happens. No problem 👍
10th Jul 2018, 9:16 AM
Dev
Dev - avatar
+ 1
Oops I didn't read the question clearly. I implicitly thought about 'raise' statement without the exception specified. Which will obviously produce an error specifying 'no active exception to reraise' I completely forgot about the usage 'raise' with an exception specified. for eg: raise ValueError But thank you for reminding me. This helped me a lot.
10th Jul 2018, 9:03 AM
Darkchylde