title: Type checking of arguments Python
body: <p>Sometimes checking of arguments in Python is necessary. e.g. I have a function which accepts either the address of other node in the network as the raw string address or class Node which encapsulates the other node's information.</p>
  
  <p>I use type() function as in:</p>
  
  <pre><code>    if type(n) == type(Node):
          do this
      elif type(n) == type(str)
          do this
  </code></pre>
  
  <p>Is this a good way to do this?</p>
  
  <p><strong>Update 1:</strong> Python 3 has annotation for function parameters. These can be used for type checks using tool: <a href="http://mypy-lang.org/" rel="nofollow noreferrer">http://mypy-lang.org/</a></p>