It would be much better to be specific here and only catch the exceptions thrown by socket.inet_pton. This for example will eat KeyboardInterrupt and prevent the user from reliably quitting the app at totally random times.