This code works when I try it from a .py file, but fails in the command line interpreter and Idle.
>>> try: ... fsock = open(\"/bla\") ... excep
You need to leave a blank line to close the except block. The ... indicates it is still trying to put code in that block, even though you dedent it. This is just a quirk of the interactive interpreter.
except
...