Yes, in theory this is a problem in lots of languages which are weakly typed. There are lots of ways of handling this, some generic and some language specific.
In python I would suggest wrapping your call in a try / expect block or using "isinstance()".
If you are using a publicly available library or popular piece of code that can return None or an Integer, I would argue that piece of code was written incorrectly. Newbie python users might do this, but I think experienced python devs would see the problem.
Finally, some documentation or justification for the reasoning behind this decision at the top of the function or on a web page somewhere would help as well.
As with most powerful , full featured languages it is pretty easy to shoot yourself in the foot if you are not careful, I don't think this is a python specific problem...
Some times one wants classes to be semantic, not only structural. That means that when the developer writes "class C(Foo)" he means something different than writting "class C(Bar)" even if both classes implement the same methods.
We really need a language that defaults to statically typed, but that can be dynamically typed where you ask nicely.
E.g. - as opposed to the Java practice of having 3 or more layers of fun to read (NOT!) XML on top of the language's native static typing to glue things together. I'm gonna be sick now...
In python I would suggest wrapping your call in a try / expect block or using "isinstance()".
If you are using a publicly available library or popular piece of code that can return None or an Integer, I would argue that piece of code was written incorrectly. Newbie python users might do this, but I think experienced python devs would see the problem.
Finally, some documentation or justification for the reasoning behind this decision at the top of the function or on a web page somewhere would help as well.
As with most powerful , full featured languages it is pretty easy to shoot yourself in the foot if you are not careful, I don't think this is a python specific problem...