Exception handling for socket.error in Python 3.5/RStudio

Martin A. Brown martin at linux-ip.net
Fri Feb 5 16:01:22 EST 2016


Hi there,

>Thanks for the detailed reply. I edited, saved and opened the file 
>again. Still I am getting exactly the same error.
>
>Putting bigger chunk of code and the error again:

[snipped; thanks for the larger chunk]

>Error:
>except socket.error as e:
>                         ^
>SyntaxError: invalid syntax

I ran your code.  I see this:

  $ python3 shaunak.bangale.py 
  Connecting...
  Connection succeeded
  Traceback (most recent call last):
    File "shaunak.bangale.py", line 23, in <module>
      ssl_sock.write(bytes(initiation_command, 'UTF-8'))
  NameError: name 'initiation_command' is not defined

Strictly speaking, I don't think you are having a Python problem.

  * Are you absolutely certain you are (or your IDE is) executing 
    the same code you are writing?

  * How would you be able to tell?  Close your IDE.  Run the code on 
    the command-line.

  * How much time have you taken to work out what the interpreter is 
    telling you?

Good luck,

-Martin

-- 
Martin A. Brown
http://linux-ip.net/



More information about the Python-list mailing list