code: def tar_file(files, tarname):
      '''Compress a file or directory into a tar file.'''
  
      if isinstance(files, basestring):
          files = [files]
  
      o = tarfile.open(tarname, 'w:gz')
      for file in files:
          o.add(file)
      o.close(f tar_file(files, tarname):
      '''Compress a file or directory into a tar file.'''
  
      if isinstance(files, basestring):
          files = [files]
  
      o = tarfile.open(tarname, 'w:gz')
      for file in files:
          o.add(file)
      o.close()
docs: Compress a file or directory into a tar file.