code: def print_trace(self, file=sys.stdout, base=10, compact=False):
          
          if len(self.trace) == 0:
              raise PyrtlError('error, cannot print an empty trace')
          if base not in (2, 8, 10, 16):
              raise PyrtlError('please choose a valid base (2,8,10,16)')
  
          basekey = {2: 'b', 8: 'o', 10: 'd', 16: 'x'}[base]
          ident_len = max(len(w) for w in self.trace)
  
          if compact:
              for w in sorted(self.trace, key=_trace_sort_key):
                  vals = ''.join('{0:{1}}'.format(x, basekey) for x in self.trace[w])
                  file.write(w.rjust(ident_len) + ' ' + vals + '\n')
          else:
              maxlenval = max(len('{0:{1}}'.format(x, basekey))
                              for w in self.trace for x in self.trace[w])
              file.write(' ' * (ident_len - 3) + "--- Values in base %d ---\n" % base)
              for w in sorted(self.trace, key=_trace_sort_key):
                  vals = ' '.join('{0:>{1}{2}}'.format(x, maxlenval, basekey) for x in self.trace[w])
                  file.write(w.ljust(ident_len + 1) + vals + '\n')
  
          file.flush()
docs: Prints a list of wires and their current values.
          :param int base: the base the values are to be printed in
          :param bool compact: whether to omit spaces in output lines