I have a function that looks like this, with many additional parameters. One of these options, somewhere among all the others, is text .
I am processing text specifically, because if it is logical, then I want to run in order to do something based on this. If this is not the case (this means that it is just a string), then I am doing something else. The code looks something like this:
def foo(self, arg1=None, arg2=None, arg3=None, ..., text=None, argN=None, ...): ... if text is not None: if type(text)==bool: if text: # Do something else: # Do something else else: # Do something else
I get the following error in the line type(text)==bool :
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "...", line 79, in foo if type(text)==bool: TypeError: 'NoneType' object is not callable
I donβt know what the problem is. Should I test type differently? The python command line experiment seems to confirm that my way of doing this should work.
source share