I have a function that looks like the following, together with a whole lot of optional parameters, from these parameters One, among all others, is text .
I handle text especially because if it is a boolean, then I want to run something based on it if it is not (which means that it is just a String is), then I do something else code looks roughly like this:
def foo (self, arg1 = none, arg2 = none, arg3 = none, .., text = none, argn = none, ...): ... if there is no text none: if type (text) == bool: if text: # do something else: # do something else I get the following error on the line type (text) == bool line: Traceback (most recent call final): File "& lt; stdin>", line 1, & lt; Module & gt; Type (text) == bool: TypeError: The 'NoneType' object is not worth the corner
Not sure what the problem is, should I test it differently? Experimenting on the dragon command line is confirming that my way of doing this should work.
I think somewhere called type is an argument, I I can reproduce my error with the following error:
& gt; & Gt; & Gt; Type ('ABC') & lt; Class 'str' & gt; & Gt; & Gt; & Gt; Type = none & gt; & Gt; & Gt; Traceback ('ABC') traceback (most recent call final): File "& lt; pyshell # 62" gt; Line 1, & lt; Module & gt; Type ('ABC') type: Error: 'Any type' object is not callable
Comments
Post a Comment