Peter Otten wrote: > try: > ... > except socket.error: > ... > > #untested > import socket > > class SocketWrapper: > def __getattr__(self, name): > return getattr(socket, name) > error = None > > import module_using_socket > module_using_socket.socket = SocketWrapper() Very interesting solution. Thanks! Regards, mk