def dnslookup(str):
 if (str == ''):
  str = ' '
 if (str[0] in string.digits):
  try:
   value = socket.gethostbyaddr(str)[0]
  except:
   value = 'Lookup failed'
 else:
  try:
   value = socket.gethostbyname(str)
  except:
   value = 'Lookup failed'
 return value

def dnslookup ( str ) : if ( str == '' ) : str = ' ' if ( str [ 0 ] in string . digits ) : try : value = socket . gethostbyaddr ( str ) [ 0 ] except : value = 'Lookup failed' else : try : value = socket . gethostbyname ( str ) except : value = 'Lookup failed' return value
perform dns lookup on str .