[Tutor] python sockets

Peter Otten __peter__ at web.de
Wed Jun 11 10:48:45 CEST 2014

Alan Gauld wrote:

> On 11/06/14 00:08, Jon Engle wrote:
>> Ok, so when I run the code it immediately terminates and never 'listens'
> This has nothing to do with your immediate problem but...
>> ***Code***
>>    #!/usr/bin/python           # This is server.py file
>>      from socket import *      #import the socket library
>>      import thread#import the thread library
>>      startingPort=input("\nPlease enter starting port: ")
>>      startingPort=int(startingPort)
> You said you were using Python 2.7.
> Do not use input() in Python v2 use raw_input() instead.
> Especially since you are using int() to convert the data anyway.
> v2 input() evaluates whatever the user types which could
> be damaging code (whether deliberate or inadvertent).
> v2 input() is so dangerous it was removed from v3 and
> raw_input renamed as input. (Which has just created lots
> of confusion IMHO!)
>>      def setup(PORT):
>> ##let's set up some constants
>> HOST = ''    #we are the host
> BTW I'm still losing nearly all indentation on your posts.
> Are you posting in plain text? Nobody else is complaining
> so it might just be my reader that's barfing on it...

No, it's not just you, I don't see any indentation either.

More information about the Tutor mailing list