I use the code:
def foo(x): print(type(x)) if x is not int: raise(TypeError) #do smth
foo(100)
The log is , but TypeError is raised. Why?
I use the code:
def foo(x): print(type(x)) if x is not int: raise(TypeError) #do smth
foo(100)
The log is , but TypeError is raised. Why?
You need to use if type(x) is not int:
def foo(x):
    print(type(x))
    if type(x) is not int:
        raise(TypeError)
So if im reading it right it should be:
def foo(x):
    if type(x) is not int:
        raise(TypeError)
  foo(100)
Im really not sure what you mean with log but maybe this helps
It's better to use isinstance() rather than type() ==. The former works for subclasses.