异常不是在ipython中引发而是在python中引发

时间:2017-10-20 10:09:12

标签: python exception-handling ipython

当我尝试创建类My_class的实例时,如果var1不是"specific value"

,它应该返回一个ValueError

班级定义:

class My_class:
def __init__(self,var1):

    if var1 != "specific value":
        raise ValueError("api_type not equal to faq")

用法:

import the_file
mc = My_class(var1= "something wrong")

在Python shell中它确实如此,但是使用IPython shell它甚至不会评估if。 有人能解释我为什么吗?

0 个答案:

没有答案