Python exit from all function and stop the execution
<p>I'm trying to develop a script that will connect to our switch and do some tasks.<br>
In this script I have a main function that calls a second function. In the second function I pass a list of switches that Python will start to connect one by one.<br>
The second function will call a third function. In the third function the script makes some tests. If one of these tests fail I want to close the entire script.<br>
The problem is that I tried to put <code>return</code>, <code>exit</code>, <code>raise System</code>, <code>os.exit</code> but what happens is that the script doesn't stop, it just jumps to another switch and goes on.</p>

<p>Anyone knows how can I close my entire script from a function?</p>

<p>Best regards. </p>