[Tutor] error_connection_refused

Steven D'Aprano steve at pearwood.info
Wed Jun 6 03:05:33 CEST 2012

BILAL Mustapha wrote:

> Here is the code:

Unfortunately not. What you have posted contains at least two SyntaxErrors 
that prevents it from running:

> def send_data():
> *print("test sending data")*
>     s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
> *s.connect((IP, PORT))*

Two of those four lines are invalid: the indentation is wrong, and there are 
leading and trailing asterisks * on the lines. Possibly your email program has 
"helpfully" added them because you marked the lines as bold for some reason.

There may be other errors I haven't spotted.

When sending code, please ensure that you send actual RUNNING code that does 
what you say it does. If you help us to run your code, we can help you fix the 

Copy and paste from the code you actually run, or attach the file to your 
email as an attachment. Double-check that your email program sends plain text, 
including correct indentation, and not HTML/Rich Text. Double-check the 
indentation is correct.

If you must add comments or annotations to the code, use Python comment syntax

# like this

and not asterisks * or formatting, or animated gifs of dancing bears, or any 
other rubbish that gets in the way of running the code.

This may also help:


Thank you,


More information about the Tutor mailing list