How to do type verification in python?
<p>(Maybe b/c I'm from a C++ world)
I want to verify some python variable is</p>

<p><code>list(string)</code> or <code>list(dict(int, string))</code> or <code>SomethingIterable(string)</code></p>

<p>Is there a simple and unified way to do it?
(Instead of writing customized code to iterate and verify each instance..)</p>

<p>I emphasize that I understand in Python <code>list</code> can have elements of different types, which is exactly the reason why I ask how to verify a <code>list</code> which are composed by just a certain type e.g. <code>string</code>.</p>

<p>Use the <a href="https://docs.python.org/3/library/typing.html" rel="nofollow">typing</a> module</p>

<p>Typically: </p>

<pre><code>from typing import List

def method(value: List[str]):
    pass
</code></pre>

python