title: In a special case, Python's try and except blocks both seem to be evaluated
body: <p>I have a simple Python code with a try block that opens a file if it exists and prints a message (M!) and exits if it doesn't exist. The except block prints a different message (M2). For some unknown reason, it prints both M1 and M2. Here is the code being executed through an interactive client but the same result is seen even when executed in non-interactive mode:-</p>
  <pre><code>Python 3.7.4 (default, Feb  7 2020, 04:54:24)
  [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux
  Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
  &gt;&gt;&gt; import sys
  &gt;&gt;&gt; import os
  &gt;&gt;&gt; os.path.isfile(&quot;test.txt&quot;)
  False
  &gt;&gt;&gt; try:
  ...     if os.path.isfile(&quot;test.txt&quot;):
  ...             open(&quot;test.txt&quot;)
  ...     else:
  ...             print(&quot;file not found&quot;)
  ...             sys.exit()
  ... except:
  ...     print(&quot;something else went wrong&quot;)
  ...
  file not found
  something else went wrong
  
  </code></pre>
  <p>Please let me know if someone could decipher what is going on?</p>