code: def _get_available_ports():
      
      if platform.system() == 'Darwin':
          return glob.glob('/dev/tty.usb*')
  
      elif platform.system() == 'Linux':
          return glob.glob('/dev/ttyACM*') + glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyAMA*')
  
      elif sys.platform.lower() == 'cygwin':
          return glob.glob('/dev/com*')
  
      elif platform.system() == 'Windows':
          import _winreg
          import itertools
  
          ports = []
          path = 'HARDWARE\\DEVICEMAP\\SERIALCOMM'
          key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, path)
  
          for i in itertools.count():
              try:
                  ports.append(str(_winreg.EnumValue(key, i)[1]))
              except WindowsError:
                  return ports
      else:
          raise EnvironmentError('{} is an unsupported platform, cannot find serial ports !'.format(platform.system()))
      return []
docs: Tries to find the available serial ports on your system.