code: def flatten(self, msg, unixfrom=False, linesep=None):
          r
          # We use the _XXX constants for operating on data that comes directly
          # from the msg, and _encoded_XXX constants for operating on data that
          # has already been converted (to bytes in the BytesGenerator) and
          # inserted into a temporary buffer.
          policy = msg.policy if self.policy is None else self.policy
          if linesep is not None:
              policy = policy.clone(linesep=linesep)
          if self.maxheaderlen is not None:
              policy = policy.clone(max_line_length=self.maxheaderlen)
          self._NL = policy.linesep
          self._encoded_NL = self._encode(self._NL)
          self._EMPTY = ''
          self._encoded_EMTPY = self._encode('')
          # Because we use clone (below) when we recursively process message
          # subparts, and because clone uses the computed policy (not None),
          # submessages will automatically get set to the computed policy when
          # they are processed by this code.
          old_gen_policy = self.policy
          old_msg_policy = msg.policy
          try:
              self.policy = policy
              msg.policy = policy
              if unixfrom:
                  ufrom = msg.get_unixfrom()
                  if not ufrom:
                      ufrom = 'From nobody ' + time.ctime(time.time())
                  self.write(ufrom + self._NL)
              self._write(msg)
          finally:
              self.policy = old_gen_policy
              msg.policy = old_msg_policy
docs: r"""Print the message object tree rooted at msg to the output file
          specified when the Generator instance was created.
  
          unixfrom is a flag that forces the printing of a Unix From_ delimiter
          before the first object in the message tree.  If the original message
          has no From_ delimiter, a `standard' one is crafted.  By default, this
          is False to inhibit the printing of any From_ delimiter.
  
          Note that for subobjects, no From_ line is printed.
  
          linesep specifies the characters used to indicate a new line in
          the output.  The default value is determined by the policy.