Function with multiple options of returns
<p>Sorry, if this question was already answered, I couldn't think of a better way to describe this problem :/</p>

<p>Let's say I have a function like this:</p>

<pre><code>def func(arg):
    if arg something:
        return a, b, c, d
    else:
        return False
</code></pre>

<p>So, when i call this function like this:</p>

<pre><code>a, b, c, d = func(arg)
</code></pre>

<p>and it happens, that the function only returns False -would this create a problem (since I'm assigning 4 variables but only getting 1 bool) ? </p>

<p>Yes it will raise a <code>ValueError</code>. You can take care of that by wrapping the assignment with a <code>try-except</code> statement:</p>

<pre><code>try:
    a, b, c, d = func(arg)
except ValueError:
    # pass or do something else
</code></pre>

<p>Note that you can also check the validation of your returned value but since it's <a href="https://docs.python.org/3.5/glossary.html" rel="nofollow">Easier to ask for forgiveness than permission</a> as a coding style manner, it's better to use a <code>try-except</code> for handling this. </p>

python function return