docs: def put(filename, target=None, serial=None):
      """
      Puts a referenced file on the LOCAL file system onto the
      file system on the BBC micro:bit.
  
      If no serial object is supplied, microfs will attempt to detect the
      connection itself.
  
      Returns True for success or raises an IOError if there's a problem.
      """
      if not os.path.isfile(filename):
          raise IOError('No such file.')
      with open(filename, 'rb') as local:
          content = local.read()
      filename = os.path.basename(filename)
      if target is None:
          target = filename
      commands = [
          "fd = open('{}', 'wb')".format(target),
          "f = fd.write",
      ]
      while content:
          line = content[:64]
          if PY2:
              commands.append('f(b' + repr(line) + ')')
          else:
              commands.append('f(' + repr(line) + ')')
          content = content[64:]
      commands.append('fd.close()')
      out, err = execute(commands, serial)
      if err:
          raise IOError(clean_error(err))
      return True