code: def get_geoip_dat ():
      
      datafiles = ("GeoIPCity.dat", "GeoIP.dat")
      if os.name == 'nt':
          paths = (sys.exec_prefix, r"c:\geoip")
      else:
          paths = ("/usr/local/share/GeoIP", "/usr/share/GeoIP")
      for path in paths:
          for datafile in datafiles:
              filename = os.path.join(path, datafile)
              if os.path.isfile(filename):
                  return filename
docs: Find a GeoIP database, preferring city over country lookup.