def python_zip(file_list, gallery_path, extension='.py'):
 zipname = gallery_path.replace(os.path.sep, '_')
 zipname += ('_python' if (extension == '.py') else '_jupyter')
 zipname = os.path.join(gallery_path, (zipname + '.zip'))
 zipf = zipfile.ZipFile(zipname, mode='w')
 for fname in file_list:
  file_src = (os.path.splitext(fname)[0] + extension)
  zipf.write(file_src)
 zipf.close()
 return zipname

def python_zip ( file_list , gallery_path , extension = '.py' ) : zipname = gallery_path . replace ( os . path . sep , '_' ) zipname += ( '_python' if ( extension == '.py' ) else '_jupyter' ) zipname = os . path . join ( gallery_path , ( zipname + '.zip' ) ) zipf = zipfile . ZipFile ( zipname , mode = 'w' ) for fname in file_list : file_src = ( os . path . splitext ( fname ) [ 0 ] + extension ) zipf . write ( file_src ) zipf . close ( ) return zipname
stores all files in file_list into an zip file parameters file_list : list of strings holds all the file names to be included in zip file gallery_path : string path to where the zipfile is stored extension : str .