code: def write(self, fieldname, value=Nothing):
          
          type = self._check(fieldname, value)
          if self._pos == -1:
              # write header
              self.stream.write('M')
              self._write_str(self.message.name)
              self._write_int(self.message.version)
              self._pos = 0
  
          writer = getattr(self, '_write_' + type)
          out = writer(value)
          self._pos += 1
          return out
docs: Write the `value` to the stream, after verifying that
          `fieldname` is the correct next field in the message
          format. `value` defaults to :class:`Nothing`, which is
          distinct from :class:`None`, as :class:`None` is a valid
          value which may be written (when a field is ``or nil``).
  
          When writing ``many`` fields, `value` should be a list
          or tuple; if not, the single value will be written for
          the field and future writes to that field will fail.
  
          If a field other than `fieldname` should be written,
          unless all preceding unwritten fields are ``or nil``,
          raise :class:`SendlibError`.
  
          Returns :class:`None`, except when writing a nested
          :class:`Message`, in which case a new
          :class:`Writer` is returned.