DEV Community

Discussion on: Why all this hate about Python?

Collapse
 
aoeu256 profile image
Alexis Rodriguez

The types of variables are constrained by the operations you use in the function definition, and of course its name. For example,
def myadd(a, b):
----return a + b
Rather than thinking about a and b as numbers [isinstance(a, Number)], think of them as variables that have the +(add) operator i.e: ['add' in a.class or hasattr(a, 'add')]. Another thing you can do is look at its callers, or setting a break point inside the function.