I have a function that looks like the following, with a whole lot of optional parameters.  One of these parameters, somewhere amidst all the others, is text.
I handle text specially because if it is a boolean, then I want to run to do something based on that.  If it's not (which means it's just a string), then I do something else.  The code looks roughly 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 on the type(text)==bool line:
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
Not sure what the problem is. Should I be testing the type differently? Experimenting on the python command line seems to confirm that my way of doing it should work.
I guess you have an argument called type somewhere, I can easily reproduce your error with the following code:
>>> type('abc')
<class 'str'>
>>> type = None
>>> type('abc')
Traceback (most recent call last):
  File "<pyshell#62>", line 1, in <module>
    type('abc')
TypeError: 'NoneType' object is not callable
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With