parthtamu/rag-code-assistant
0
1<!DOCTYPE html>2 3<html lang="en" data-content_root="../">4 <head>5 <meta charset="utf-8" />6 <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />7<meta property="og:title" content="gzip — Support for gzip files" />8<meta property="og:type" content="website" />9<meta property="og:url" content="https://docs.python.org/3/library/gzip.html" />10<meta property="og:site_name" content="Python documentation" />11<meta property="og:description" content="Source code: Lib/gzip.py This module provides a simple interface to compress and decompress files just like the GNU programs gzip and gunzip would. This is an optional module. If it is missing from..." />12<meta property="og:image:width" content="1146" />13<meta property="og:image:height" content="600" />14<meta property="og:image" content="https://docs.python.org/3.15/_images/social_previews/summary_library_gzip_6382a92a.png" />15<meta property="og:image:alt" content="Source code: Lib/gzip.py This module provides a simple interface to compress and decompress files just like the GNU programs gzip and gunzip would. This is an optional module. If it is missing from..." />16<meta name="description" content="Source code: Lib/gzip.py This module provides a simple interface to compress and decompress files just like the GNU programs gzip and gunzip would. This is an optional module. If it is missing from..." />17<meta name="twitter:card" content="summary_large_image" />18<meta name="theme-color" content="#3776ab">19 20 <title>gzip — Support for gzip files — Python 3.15.0a6 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">21 22 <link rel="stylesheet" type="text/css" href="../_static/pygments.css?v=b86133f3" />23 <link rel="stylesheet" type="text/css" href="../_static/classic.css?v=234b1a7c" />24 <link rel="stylesheet" type="text/css" href="../_static/pydoctheme.css?v=89a2f22a" />25 <link rel="stylesheet" type="text/css" href="../_static/profiling-sampling-visualization.css?v=0c2600ae" />26 <link id="pygments_dark_css" media="(prefers-color-scheme: dark)" rel="stylesheet" type="text/css" href="../_static/pygments_dark.css?v=5349f25f" />27 28 <script src="../_static/documentation_options.js?v=6b7c9ff5"></script>29 <script src="../_static/doctools.js?v=9bcbadda"></script>30 <script src="../_static/sphinx_highlight.js?v=dc90522c"></script>31 <script src="../_static/profiling-sampling-visualization.js?v=9811ed04"></script>32 33 <script src="../_static/sidebar.js"></script>34 35 <link rel="search" type="application/opensearchdescription+xml"36 title="Search within Python 3.15.0a6 documentation"37 href="../_static/opensearch.xml"/>38 <link rel="author" title="About these documents" href="../about.html" />39 <link rel="index" title="Index" href="../genindex.html" />40 <link rel="search" title="Search" href="../search.html" />41 <link rel="copyright" title="Copyright" href="../copyright.html" />42 <link rel="next" title="bz2 — Support for bzip2 compression" href="bz2.html" />43 <link rel="prev" title="zlib — Compression compatible with gzip" href="zlib.html" />44 45 46 <script defer file-types="bz2,epub,zip" data-domain="docs.python.org" src="https://analytics.python.org/js/script.file-downloads.outbound-links.js"></script>47 48 <link rel="canonical" href="https://docs.python.org/3/library/gzip.html">49 50 51 52 53 <style>54 @media only screen {55 table.full-width-table {56 width: 100%;57 }58 }59 </style>60<link rel="stylesheet" href="../_static/pydoctheme_dark.css" media="(prefers-color-scheme: dark)" id="pydoctheme_dark_css">61 <link rel="shortcut icon" type="image/png" href="../_static/py.svg">62 <script type="text/javascript" src="../_static/copybutton.js"></script>63 <script type="text/javascript" src="../_static/menu.js"></script>64 <script type="text/javascript" src="../_static/search-focus.js"></script>65 <script type="text/javascript" src="../_static/themetoggle.js"></script> 66 <script type="text/javascript" src="../_static/rtd_switcher.js"></script>67 <meta name="readthedocs-addons-api-version" content="1">68 69 </head>70<body>71<div class="mobile-nav">72 <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"73 aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu">74 <nav class="nav-content" role="navigation">75 <label for="menuToggler" class="toggler__label">76 <span></span>77 </label>78 <span class="nav-items-wrapper">79 <a href="https://www.python.org/" class="nav-logo">80 <img src="../_static/py.svg" alt="Python logo">81 </a>82 <span class="version_switcher_placeholder"></span>83 <form role="search" class="search" action="../search.html" method="get">84 <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">85 <path fill-rule="nonzero" fill="currentColor" d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path>86 </svg>87 <input placeholder="Quick search" aria-label="Quick search" type="search" name="q">88 <input type="submit" value="Go">89 </form>90 </span>91 </nav>92 <div class="menu-wrapper">93 <nav class="menu" role="navigation" aria-label="main navigation">94 <div class="language_switcher_placeholder"></div>95 96<label class="theme-selector-label">97 Theme98 <select class="theme-selector" oninput="activateTheme(this.value)">99 <option value="auto" selected>Auto</option>100 <option value="light">Light</option>101 <option value="dark">Dark</option>102 </select>103</label>104 <div>105 <h3><a href="../contents.html">Table of Contents</a></h3>106 <ul>107<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">gzip</span></code> — Support for <strong class="program">gzip</strong> files</a><ul>108<li><a class="reference internal" href="#examples-of-usage">Examples of usage</a></li>109<li><a class="reference internal" href="#command-line-interface">Command-line interface</a><ul>110<li><a class="reference internal" href="#command-line-options">Command-line options</a></li>111</ul>112</li>113</ul>114</li>115</ul>116 117 </div>118 <div>119 <h4>Previous topic</h4>120 <p class="topless"><a href="zlib.html"121 title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">zlib</span></code> — Compression compatible with <strong class="program">gzip</strong></a></p>122 </div>123 <div>124 <h4>Next topic</h4>125 <p class="topless"><a href="bz2.html"126 title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">bz2</span></code> — Support for <strong class="program">bzip2</strong> compression</a></p>127 </div>128 <script>129 document.addEventListener('DOMContentLoaded', () => {130 const title = document.querySelector('meta[property="og:title"]').content;131 const elements = document.querySelectorAll('.improvepage');132 const pageurl = window.location.href.split('?')[0];133 elements.forEach(element => {134 const url = new URL(element.href.split('?')[0].replace("-nojs", ""));135 url.searchParams.set('pagetitle', title);136 url.searchParams.set('pageurl', pageurl);137 url.searchParams.set('pagesource', "library/gzip.rst");138 element.href = url.toString();139 });140 });141 </script>142 <div role="note" aria-label="source link">143 <h3>This page</h3>144 <ul class="this-page-menu">145 <li><a href="../bugs.html">Report a bug</a></li>146 <li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>147 <li>148 <a href="https://github.com/python/cpython/blob/main/Doc/library/gzip.rst?plain=1"149 rel="nofollow">Show source150 </a>151 </li>152 153 </ul>154 </div>155 </nav>156 </div>157</div>158 159 160 <div class="related" role="navigation" aria-label="Related">161 <h3>Navigation</h3>162 <ul>163 <li class="right" style="margin-right: 10px">164 <a href="../genindex.html" title="General Index"165 accesskey="I">index</a></li>166 <li class="right" >167 <a href="../py-modindex.html" title="Python Module Index"168 >modules</a> |</li>169 <li class="right" >170 <a href="bz2.html" title="bz2 — Support for bzip2 compression"171 accesskey="N">next</a> |</li>172 <li class="right" >173 <a href="zlib.html" title="zlib — Compression compatible with gzip"174 accesskey="P">previous</a> |</li>175 176 <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>177 <li><a href="https://www.python.org/">Python</a> »</li>178 <li class="switchers">179 <div class="language_switcher_placeholder"></div>180 <div class="version_switcher_placeholder"></div>181 </li>182 <li>183 184 </li>185 <li id="cpython-language-and-version">186 <a href="../index.html">3.15.0a6 Documentation</a> »187 </li>188 189 <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li>190 <li class="nav-item nav-item-2"><a href="archiving.html" accesskey="U">Data Compression and Archiving</a> »</li>191 <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">gzip</span></code> — Support for <strong class="program">gzip</strong> files</a></li>192 <li class="right">193 194 195 <div class="inline-search" role="search">196 <form class="inline-search" action="../search.html" method="get">197 <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">198 <input type="submit" value="Go">199 </form>200 </div>201 |202 </li>203 <li class="right">204<label class="theme-selector-label">205 Theme206 <select class="theme-selector" oninput="activateTheme(this.value)">207 <option value="auto" selected>Auto</option>208 <option value="light">Light</option>209 <option value="dark">Dark</option>210 </select>211</label> |</li>212 213 </ul>214 </div> 215 216 <div class="document">217 <div class="documentwrapper">218 <div class="bodywrapper">219 <div class="body" role="main">220 221 <section id="module-gzip">222<span id="gzip-support-for-gzip-files"></span><h1><code class="xref py py-mod docutils literal notranslate"><span class="pre">gzip</span></code> — Support for <strong class="program">gzip</strong> files<a class="headerlink" href="#module-gzip" title="Link to this heading">¶</a></h1>223<p><strong>Source code:</strong> <a class="extlink-source reference external" href="https://github.com/python/cpython/tree/main/Lib/gzip.py">Lib/gzip.py</a></p>224<hr class="docutils" />225<p>This module provides a simple interface to compress and decompress files just226like the GNU programs <strong class="program">gzip</strong> and <strong class="program">gunzip</strong> would.</p>227<p>This is an <a class="reference internal" href="../glossary.html#term-optional-module"><span class="xref std std-term">optional module</span></a>.228If it is missing from your copy of CPython,229look for documentation from your distributor (that is,230whoever provided Python to you).231If you are the distributor, see <a class="reference internal" href="../using/configure.html#optional-module-requirements"><span class="std std-ref">Requirements for optional modules</span></a>.</p>232<p>The data compression is provided by the <a class="reference internal" href="zlib.html#module-zlib" title="zlib: Low-level interface to compression and decompression routines compatible with gzip."><code class="xref py py-mod docutils literal notranslate"><span class="pre">zlib</span></code></a> module.</p>233<p>The <code class="xref py py-mod docutils literal notranslate"><span class="pre">gzip</span></code> module provides the <a class="reference internal" href="#gzip.GzipFile" title="gzip.GzipFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">GzipFile</span></code></a> class, as well as the234<a class="reference internal" href="#gzip.open" title="gzip.open"><code class="xref py py-func docutils literal notranslate"><span class="pre">open()</span></code></a>, <a class="reference internal" href="#gzip.compress" title="gzip.compress"><code class="xref py py-func docutils literal notranslate"><span class="pre">compress()</span></code></a> and <a class="reference internal" href="#gzip.decompress" title="gzip.decompress"><code class="xref py py-func docutils literal notranslate"><span class="pre">decompress()</span></code></a> convenience functions.235The <code class="xref py py-class docutils literal notranslate"><span class="pre">GzipFile</span></code> class reads and writes <strong class="program">gzip</strong>-format files,236automatically compressing or decompressing the data so that it looks like an237ordinary <a class="reference internal" href="../glossary.html#term-file-object"><span class="xref std std-term">file object</span></a>.</p>238<p>Note that additional file formats which can be decompressed by the239<strong class="program">gzip</strong> and <strong class="program">gunzip</strong> programs, such as those produced by240<strong class="program">compress</strong> and <strong class="program">pack</strong>, are not supported by this module.</p>241<p>The module defines the following items:</p>242<dl class="py function">243<dt class="sig sig-object py" id="gzip.open">244<span class="sig-prename descclassname"><span class="pre">gzip.</span></span><span class="sig-name descname"><span class="pre">open</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filename</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'rb'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">compresslevel</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">6</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">encoding</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">errors</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">newline</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#gzip.open" title="Link to this definition">¶</a></dt>245<dd><p>Open a gzip-compressed file in binary or text mode, returning a <a class="reference internal" href="../glossary.html#term-file-object"><span class="xref std std-term">file246object</span></a>.</p>247<p>The <em>filename</em> argument can be an actual filename (a <a class="reference internal" href="stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a> or248<a class="reference internal" href="stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> object), or an existing file object to read from or write to.</p>249<p>The <em>mode</em> argument can be any of <code class="docutils literal notranslate"><span class="pre">'r'</span></code>, <code class="docutils literal notranslate"><span class="pre">'rb'</span></code>, <code class="docutils literal notranslate"><span class="pre">'a'</span></code>, <code class="docutils literal notranslate"><span class="pre">'ab'</span></code>,250<code class="docutils literal notranslate"><span class="pre">'w'</span></code>, <code class="docutils literal notranslate"><span class="pre">'wb'</span></code>, <code class="docutils literal notranslate"><span class="pre">'x'</span></code> or <code class="docutils literal notranslate"><span class="pre">'xb'</span></code> for binary mode, or <code class="docutils literal notranslate"><span class="pre">'rt'</span></code>,251<code class="docutils literal notranslate"><span class="pre">'at'</span></code>, <code class="docutils literal notranslate"><span class="pre">'wt'</span></code>, or <code class="docutils literal notranslate"><span class="pre">'xt'</span></code> for text mode. The default is <code class="docutils literal notranslate"><span class="pre">'rb'</span></code>.</p>252<p>The <em>compresslevel</em> argument is an integer from 0 to 9, as for the253<a class="reference internal" href="#gzip.GzipFile" title="gzip.GzipFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">GzipFile</span></code></a> constructor.</p>254<p>For binary mode, this function is equivalent to the <a class="reference internal" href="#gzip.GzipFile" title="gzip.GzipFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">GzipFile</span></code></a>255constructor: <code class="docutils literal notranslate"><span class="pre">GzipFile(filename,</span> <span class="pre">mode,</span> <span class="pre">compresslevel)</span></code>. In this case, the256<em>encoding</em>, <em>errors</em> and <em>newline</em> arguments must not be provided.</p>257<p>For text mode, a <a class="reference internal" href="#gzip.GzipFile" title="gzip.GzipFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">GzipFile</span></code></a> object is created, and wrapped in an258<a class="reference internal" href="io.html#io.TextIOWrapper" title="io.TextIOWrapper"><code class="xref py py-class docutils literal notranslate"><span class="pre">io.TextIOWrapper</span></code></a> instance with the specified encoding, error259handling behavior, and line ending(s).</p>260<div class="versionchanged">261<p><span class="versionmodified changed">Changed in version 3.3: </span>Added support for <em>filename</em> being a file object, support for text mode,262and the <em>encoding</em>, <em>errors</em> and <em>newline</em> arguments.</p>263</div>264<div class="versionchanged">265<p><span class="versionmodified changed">Changed in version 3.4: </span>Added support for the <code class="docutils literal notranslate"><span class="pre">'x'</span></code>, <code class="docutils literal notranslate"><span class="pre">'xb'</span></code> and <code class="docutils literal notranslate"><span class="pre">'xt'</span></code> modes.</p>266</div>267<div class="versionchanged">268<p><span class="versionmodified changed">Changed in version 3.6: </span>Accepts a <a class="reference internal" href="../glossary.html#term-path-like-object"><span class="xref std std-term">path-like object</span></a>.</p>269</div>270<div class="versionchanged">271<p><span class="versionmodified changed">Changed in version 3.15: </span>The default compression level was reduced to 6 (down from 9).272It is the default level used by most compression tools and a better273tradeoff between speed and performance.</p>274</div>275</dd></dl>276 277<dl class="py exception">278<dt class="sig sig-object py" id="gzip.BadGzipFile">279<em class="property"><span class="k"><span class="pre">exception</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">gzip.</span></span><span class="sig-name descname"><span class="pre">BadGzipFile</span></span><a class="headerlink" href="#gzip.BadGzipFile" title="Link to this definition">¶</a></dt>280<dd><p>An exception raised for invalid gzip files. It inherits from <a class="reference internal" href="exceptions.html#OSError" title="OSError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">OSError</span></code></a>.281<a class="reference internal" href="exceptions.html#EOFError" title="EOFError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">EOFError</span></code></a> and <a class="reference internal" href="zlib.html#zlib.error" title="zlib.error"><code class="xref py py-exc docutils literal notranslate"><span class="pre">zlib.error</span></code></a> can also be raised for invalid gzip282files.</p>283<div class="versionadded">284<p><span class="versionmodified added">Added in version 3.8.</span></p>285</div>286</dd></dl>287 288<dl class="py class">289<dt class="sig sig-object py" id="gzip.GzipFile">290<em class="property"><span class="k"><span class="pre">class</span></span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">gzip.</span></span><span class="sig-name descname"><span class="pre">GzipFile</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filename</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mode</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">compresslevel</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">6</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fileobj</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">mtime</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#gzip.GzipFile" title="Link to this definition">¶</a></dt>291<dd><p>Constructor for the <code class="xref py py-class docutils literal notranslate"><span class="pre">GzipFile</span></code> class, which simulates most of the292methods of a <a class="reference internal" href="../glossary.html#term-file-object"><span class="xref std std-term">file object</span></a>, with the exception of the <a class="reference internal" href="io.html#io.IOBase.truncate" title="io.IOBase.truncate"><code class="xref py py-meth docutils literal notranslate"><span class="pre">truncate()</span></code></a>293method. At least one of <em>fileobj</em> and <em>filename</em> must be given a non-trivial294value.</p>295<p>The new class instance is based on <em>fileobj</em>, which can be a regular file, an296<a class="reference internal" href="io.html#io.BytesIO" title="io.BytesIO"><code class="xref py py-class docutils literal notranslate"><span class="pre">io.BytesIO</span></code></a> object, or any other object which simulates a file. It297defaults to <code class="docutils literal notranslate"><span class="pre">None</span></code>, in which case <em>filename</em> is opened to provide a file298object.</p>299<p>When <em>fileobj</em> is not <code class="docutils literal notranslate"><span class="pre">None</span></code>, the <em>filename</em> argument is only used to be300included in the <strong class="program">gzip</strong> file header, which may include the original301filename of the uncompressed file. It defaults to the filename of <em>fileobj</em>, if302discernible; otherwise, it defaults to the empty string, and in this case the303original filename is not included in the header.</p>304<p>The <em>mode</em> argument can be any of <code class="docutils literal notranslate"><span class="pre">'r'</span></code>, <code class="docutils literal notranslate"><span class="pre">'rb'</span></code>, <code class="docutils literal notranslate"><span class="pre">'a'</span></code>, <code class="docutils literal notranslate"><span class="pre">'ab'</span></code>, <code class="docutils literal notranslate"><span class="pre">'w'</span></code>,305<code class="docutils literal notranslate"><span class="pre">'wb'</span></code>, <code class="docutils literal notranslate"><span class="pre">'x'</span></code>, or <code class="docutils literal notranslate"><span class="pre">'xb'</span></code>, depending on whether the file will be read or306written. The default is the mode of <em>fileobj</em> if discernible; otherwise, the307default is <code class="docutils literal notranslate"><span class="pre">'rb'</span></code>. In future Python releases the mode of <em>fileobj</em> will308not be used. It is better to always specify <em>mode</em> for writing.</p>309<p>Note that the file is always opened in binary mode. To open a compressed file310in text mode, use <a class="reference internal" href="#gzip.open" title="gzip.open"><code class="xref py py-func docutils literal notranslate"><span class="pre">open()</span></code></a> (or wrap your <code class="xref py py-class docutils literal notranslate"><span class="pre">GzipFile</span></code> with an311<a class="reference internal" href="io.html#io.TextIOWrapper" title="io.TextIOWrapper"><code class="xref py py-class docutils literal notranslate"><span class="pre">io.TextIOWrapper</span></code></a>).</p>312<p>The <em>compresslevel</em> argument is an integer from <code class="docutils literal notranslate"><span class="pre">0</span></code> to <code class="docutils literal notranslate"><span class="pre">9</span></code> controlling313the level of compression; <code class="docutils literal notranslate"><span class="pre">1</span></code> is fastest and produces the least314compression, and <code class="docutils literal notranslate"><span class="pre">9</span></code> is slowest and produces the most compression. <code class="docutils literal notranslate"><span class="pre">0</span></code>315is no compression. The default is <code class="docutils literal notranslate"><span class="pre">9</span></code>.</p>316<p>The optional <em>mtime</em> argument is the timestamp requested by gzip. The time317is in Unix format, i.e., seconds since 00:00:00 UTC, January 1, 1970.318If <em>mtime</em> is omitted or <code class="docutils literal notranslate"><span class="pre">None</span></code>, the current time is used. Use <em>mtime</em> = 0319to generate a compressed stream that does not depend on creation time.</p>320<p>See below for the <a class="reference internal" href="#gzip.GzipFile.mtime" title="gzip.GzipFile.mtime"><code class="xref py py-attr docutils literal notranslate"><span class="pre">mtime</span></code></a> attribute that is set when decompressing.</p>321<p>Calling a <code class="xref py py-class docutils literal notranslate"><span class="pre">GzipFile</span></code> object’s <code class="xref py py-meth docutils literal notranslate"><span class="pre">close()</span></code> method does not close322<em>fileobj</em>, since you might wish to append more material after the compressed323data. This also allows you to pass an <a class="reference internal" href="io.html#io.BytesIO" title="io.BytesIO"><code class="xref py py-class docutils literal notranslate"><span class="pre">io.BytesIO</span></code></a> object opened for324writing as <em>fileobj</em>, and retrieve the resulting memory buffer using the325<code class="xref py py-class docutils literal notranslate"><span class="pre">io.BytesIO</span></code> object’s <a class="reference internal" href="io.html#io.BytesIO.getvalue" title="io.BytesIO.getvalue"><code class="xref py py-meth docutils literal notranslate"><span class="pre">getvalue()</span></code></a> method.</p>326<p><code class="xref py py-class docutils literal notranslate"><span class="pre">GzipFile</span></code> supports the <a class="reference internal" href="io.html#io.BufferedIOBase" title="io.BufferedIOBase"><code class="xref py py-class docutils literal notranslate"><span class="pre">io.BufferedIOBase</span></code></a> interface,327including iteration and the <a class="reference internal" href="../reference/compound_stmts.html#with"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">with</span></code></a> statement. Only the328<a class="reference internal" href="io.html#io.IOBase.truncate" title="io.IOBase.truncate"><code class="xref py py-meth docutils literal notranslate"><span class="pre">truncate()</span></code></a> method isn’t implemented.</p>329<p><code class="xref py py-class docutils literal notranslate"><span class="pre">GzipFile</span></code> also provides the following method and attribute:</p>330<dl class="py method">331<dt class="sig sig-object py" id="gzip.GzipFile.peek">332<span class="sig-name descname"><span class="pre">peek</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#gzip.GzipFile.peek" title="Link to this definition">¶</a></dt>333<dd><p>Read <em>n</em> uncompressed bytes without advancing the file position.334The number of bytes returned may be more or less than requested.</p>335<div class="admonition note">336<p class="admonition-title">Note</p>337<p>While calling <code class="xref py py-meth docutils literal notranslate"><span class="pre">peek()</span></code> does not change the file position of338the <code class="xref py py-class docutils literal notranslate"><span class="pre">GzipFile</span></code>, it may change the position of the underlying339file object (e.g. if the <code class="xref py py-class docutils literal notranslate"><span class="pre">GzipFile</span></code> was constructed with the340<em>fileobj</em> parameter).</p>341</div>342<div class="versionadded">343<p><span class="versionmodified added">Added in version 3.2.</span></p>344</div>345</dd></dl>346 347<dl class="py attribute">348<dt class="sig sig-object py" id="gzip.GzipFile.mode">349<span class="sig-name descname"><span class="pre">mode</span></span><a class="headerlink" href="#gzip.GzipFile.mode" title="Link to this definition">¶</a></dt>350<dd><p><code class="docutils literal notranslate"><span class="pre">'rb'</span></code> for reading and <code class="docutils literal notranslate"><span class="pre">'wb'</span></code> for writing.</p>351<div class="versionchanged">352<p><span class="versionmodified changed">Changed in version 3.13: </span>In previous versions it was an integer <code class="docutils literal notranslate"><span class="pre">1</span></code> or <code class="docutils literal notranslate"><span class="pre">2</span></code>.</p>353</div>354</dd></dl>355 356<dl class="py attribute">357<dt class="sig sig-object py" id="gzip.GzipFile.mtime">358<span class="sig-name descname"><span class="pre">mtime</span></span><a class="headerlink" href="#gzip.GzipFile.mtime" title="Link to this definition">¶</a></dt>359<dd><p>When decompressing, this attribute is set to the last timestamp in the most360recently read header. It is an integer, holding the number of seconds361since the Unix epoch (00:00:00 UTC, January 1, 1970).362The initial value before reading any headers is <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>363</dd></dl>364 365<dl class="py attribute">366<dt class="sig sig-object py" id="gzip.GzipFile.name">367<span class="sig-name descname"><span class="pre">name</span></span><a class="headerlink" href="#gzip.GzipFile.name" title="Link to this definition">¶</a></dt>368<dd><p>The path to the gzip file on disk, as a <a class="reference internal" href="stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a> or <a class="reference internal" href="stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a>.369Equivalent to the output of <a class="reference internal" href="os.html#os.fspath" title="os.fspath"><code class="xref py py-func docutils literal notranslate"><span class="pre">os.fspath()</span></code></a> on the original input path,370with no other normalization, resolution or expansion.</p>371</dd></dl>372 373<div class="versionchanged">374<p><span class="versionmodified changed">Changed in version 3.1: </span>Support for the <a class="reference internal" href="../reference/compound_stmts.html#with"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">with</span></code></a> statement was added, along with the375<em>mtime</em> constructor argument and <a class="reference internal" href="#gzip.GzipFile.mtime" title="gzip.GzipFile.mtime"><code class="xref py py-attr docutils literal notranslate"><span class="pre">mtime</span></code></a> attribute.</p>376</div>377<div class="versionchanged">378<p><span class="versionmodified changed">Changed in version 3.2: </span>Support for zero-padded and unseekable files was added.</p>379</div>380<div class="versionchanged">381<p><span class="versionmodified changed">Changed in version 3.3: </span>The <a class="reference internal" href="io.html#io.BufferedIOBase.read1" title="io.BufferedIOBase.read1"><code class="xref py py-meth docutils literal notranslate"><span class="pre">io.BufferedIOBase.read1()</span></code></a> method is now implemented.</p>382</div>383<div class="versionchanged">384<p><span class="versionmodified changed">Changed in version 3.4: </span>Added support for the <code class="docutils literal notranslate"><span class="pre">'x'</span></code> and <code class="docutils literal notranslate"><span class="pre">'xb'</span></code> modes.</p>385</div>386<div class="versionchanged">387<p><span class="versionmodified changed">Changed in version 3.5: </span>Added support for writing arbitrary388<a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like objects</span></a>.389The <a class="reference internal" href="io.html#io.BufferedIOBase.read" title="io.BufferedIOBase.read"><code class="xref py py-meth docutils literal notranslate"><span class="pre">read()</span></code></a> method now accepts an argument of390<code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>391</div>392<div class="versionchanged">393<p><span class="versionmodified changed">Changed in version 3.6: </span>Accepts a <a class="reference internal" href="../glossary.html#term-path-like-object"><span class="xref std std-term">path-like object</span></a>.</p>394</div>395<div class="deprecated">396<p><span class="versionmodified deprecated">Deprecated since version 3.9: </span>Opening <code class="xref py py-class docutils literal notranslate"><span class="pre">GzipFile</span></code> for writing without specifying the <em>mode</em>397argument is deprecated.</p>398</div>399<div class="versionchanged">400<p><span class="versionmodified changed">Changed in version 3.12: </span>Remove the <code class="docutils literal notranslate"><span class="pre">filename</span></code> attribute, use the <a class="reference internal" href="#gzip.GzipFile.name" title="gzip.GzipFile.name"><code class="xref py py-attr docutils literal notranslate"><span class="pre">name</span></code></a>401attribute instead.</p>402</div>403<div class="versionchanged">404<p><span class="versionmodified changed">Changed in version 3.15: </span>The default compression level was reduced to 6 (down from 9).405It is the default level used by most compression tools and a better406tradeoff between speed and performance.</p>407</div>408</dd></dl>409 410<dl class="py function">411<dt class="sig sig-object py" id="gzip.compress">412<span class="sig-prename descclassname"><span class="pre">gzip.</span></span><span class="sig-name descname"><span class="pre">compress</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">compresslevel</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">6</span></span></em>, <em class="sig-param"><span class="keyword-only-separator o"><abbr title="Keyword-only parameters separator (PEP 3102)"><span class="pre">*</span></abbr></span></em>, <em class="sig-param"><span class="n"><span class="pre">mtime</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#gzip.compress" title="Link to this definition">¶</a></dt>413<dd><p>Compress the <em>data</em>, returning a <a class="reference internal" href="stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> object containing414the compressed data. <em>compresslevel</em> and <em>mtime</em> have the same meaning as in415the <a class="reference internal" href="#gzip.GzipFile" title="gzip.GzipFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">GzipFile</span></code></a> constructor above,416but <em>mtime</em> defaults to 0 for reproducible output.</p>417<div class="versionadded">418<p><span class="versionmodified added">Added in version 3.2.</span></p>419</div>420<div class="versionchanged">421<p><span class="versionmodified changed">Changed in version 3.8: </span>Added the <em>mtime</em> parameter for reproducible output.</p>422</div>423<div class="versionchanged">424<p><span class="versionmodified changed">Changed in version 3.11: </span>Speed is improved by compressing all data at once instead of in a425streamed fashion. Calls with <em>mtime</em> set to <code class="docutils literal notranslate"><span class="pre">0</span></code> are delegated to426<a class="reference internal" href="zlib.html#zlib.compress" title="zlib.compress"><code class="xref py py-func docutils literal notranslate"><span class="pre">zlib.compress()</span></code></a> for better speed. In this situation the427output may contain a gzip header “OS” byte value other than 255428“unknown” as supplied by the underlying zlib implementation.</p>429</div>430<div class="versionchanged">431<p><span class="versionmodified changed">Changed in version 3.13: </span>The gzip header OS byte is guaranteed to be set to 255 when this function432is used as was the case in 3.10 and earlier.</p>433</div>434<div class="versionchanged">435<p><span class="versionmodified changed">Changed in version 3.14: </span>The <em>mtime</em> parameter now defaults to 0 for reproducible output.436For the previous behaviour of using the current time,437pass <code class="docutils literal notranslate"><span class="pre">None</span></code> to <em>mtime</em>.</p>438</div>439<div class="versionchanged">440<p><span class="versionmodified changed">Changed in version 3.15: </span>The default compression level was reduced to 6 (down from 9).441It is the default level used by most compression tools and a better442tradeoff between speed and performance.</p>443</div>444</dd></dl>445 446<dl class="py function">447<dt class="sig sig-object py" id="gzip.decompress">448<span class="sig-prename descclassname"><span class="pre">gzip.</span></span><span class="sig-name descname"><span class="pre">decompress</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">data</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#gzip.decompress" title="Link to this definition">¶</a></dt>449<dd><p>Decompress the <em>data</em>, returning a <a class="reference internal" href="stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> object containing the450uncompressed data. This function is capable of decompressing multi-member451gzip data (multiple gzip blocks concatenated together). When the data is452certain to contain only one member the <a class="reference internal" href="zlib.html#zlib.decompress" title="zlib.decompress"><code class="xref py py-func docutils literal notranslate"><span class="pre">zlib.decompress()</span></code></a> function with453<em>wbits</em> set to 31 is faster.</p>454<div class="versionadded">455<p><span class="versionmodified added">Added in version 3.2.</span></p>456</div>457<div class="versionchanged">458<p><span class="versionmodified changed">Changed in version 3.11: </span>Speed is improved by decompressing members at once in memory instead of in459a streamed fashion.</p>460</div>461</dd></dl>462 463<section id="examples-of-usage">464<span id="gzip-usage-examples"></span><h2>Examples of usage<a class="headerlink" href="#examples-of-usage" title="Link to this heading">¶</a></h2>465<p>Example of how to read a compressed file:</p>466<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">gzip</span>467<span class="k">with</span> <span class="n">gzip</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="s1">'/home/joe/file.txt.gz'</span><span class="p">,</span> <span class="s1">'rb'</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>468 <span class="n">file_content</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>469</pre></div>470</div>471<p>Example of how to create a compressed GZIP file:</p>472<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">gzip</span>473<span class="n">content</span> <span class="o">=</span> <span class="sa">b</span><span class="s2">"Lots of content here"</span>474<span class="k">with</span> <span class="n">gzip</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="s1">'/home/joe/file.txt.gz'</span><span class="p">,</span> <span class="s1">'wb'</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>475 <span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">content</span><span class="p">)</span>476</pre></div>477</div>478<p>Example of how to GZIP compress an existing file:</p>479<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">gzip</span>480<span class="kn">import</span><span class="w"> </span><span class="nn">shutil</span>481<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="s1">'/home/joe/file.txt'</span><span class="p">,</span> <span class="s1">'rb'</span><span class="p">)</span> <span class="k">as</span> <span class="n">f_in</span><span class="p">:</span>482 <span class="k">with</span> <span class="n">gzip</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="s1">'/home/joe/file.txt.gz'</span><span class="p">,</span> <span class="s1">'wb'</span><span class="p">)</span> <span class="k">as</span> <span class="n">f_out</span><span class="p">:</span>483 <span class="n">shutil</span><span class="o">.</span><span class="n">copyfileobj</span><span class="p">(</span><span class="n">f_in</span><span class="p">,</span> <span class="n">f_out</span><span class="p">)</span>484</pre></div>485</div>486<p>Example of how to GZIP compress a binary string:</p>487<div class="highlight-python3 notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span><span class="w"> </span><span class="nn">gzip</span>488<span class="n">s_in</span> <span class="o">=</span> <span class="sa">b</span><span class="s2">"Lots of content here"</span>489<span class="n">s_out</span> <span class="o">=</span> <span class="n">gzip</span><span class="o">.</span><span class="n">compress</span><span class="p">(</span><span class="n">s_in</span><span class="p">)</span>490</pre></div>491</div>492<div class="admonition seealso">493<p class="admonition-title">See also</p>494<dl class="simple">495<dt>Module <a class="reference internal" href="zlib.html#module-zlib" title="zlib: Low-level interface to compression and decompression routines compatible with gzip."><code class="xref py py-mod docutils literal notranslate"><span class="pre">zlib</span></code></a></dt><dd><p>The basic data compression module needed to support the <strong class="program">gzip</strong> file496format.</p>497</dd>498</dl>499<p>In case gzip (de)compression is a bottleneck, the <a class="reference external" href="https://github.com/pycompression/python-isal">python-isal</a>500package speeds up (de)compression with a mostly compatible API.</p>501</div>502</section>503<section id="command-line-interface">504<span id="gzip-cli"></span><h2>Command-line interface<a class="headerlink" href="#command-line-interface" title="Link to this heading">¶</a></h2>505<p>The <code class="xref py py-mod docutils literal notranslate"><span class="pre">gzip</span></code> module provides a simple command line interface to compress or506decompress files.</p>507<p>Once executed the <code class="xref py py-mod docutils literal notranslate"><span class="pre">gzip</span></code> module keeps the input file(s).</p>508<div class="versionchanged">509<p><span class="versionmodified changed">Changed in version 3.8: </span>Add a new command line interface with a usage.510By default, when you will execute the CLI, the default compression level is 6.</p>511</div>512<section id="command-line-options">513<h3>Command-line options<a class="headerlink" href="#command-line-options" title="Link to this heading">¶</a></h3>514<dl class="std option">515<dt class="sig sig-object std" id="cmdoption-gzip-arg-file">516<span class="sig-name descname"><span class="pre">file</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-gzip-arg-file" title="Link to this definition">¶</a></dt>517<dd><p>If <em>file</em> is not specified, read from <a class="reference internal" href="sys.html#sys.stdin" title="sys.stdin"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stdin</span></code></a>.</p>518</dd></dl>519 520<dl class="std option">521<dt class="sig sig-object std" id="cmdoption-gzip-fast">522<span class="sig-name descname"><span class="pre">--fast</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-gzip-fast" title="Link to this definition">¶</a></dt>523<dd><p>Indicates the fastest compression method (less compression).</p>524</dd></dl>525 526<dl class="std option">527<dt class="sig sig-object std" id="cmdoption-gzip-best">528<span class="sig-name descname"><span class="pre">--best</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-gzip-best" title="Link to this definition">¶</a></dt>529<dd><p>Indicates the slowest compression method (best compression).</p>530</dd></dl>531 532<dl class="std option">533<dt class="sig sig-object std" id="cmdoption-gzip-d">534<span id="cmdoption-gzip-decompress"></span><span class="sig-name descname"><span class="pre">-d</span></span><span class="sig-prename descclassname"></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">--decompress</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-gzip-d" title="Link to this definition">¶</a></dt>535<dd><p>Decompress the given file.</p>536</dd></dl>537 538<dl class="std option">539<dt class="sig sig-object std" id="cmdoption-gzip-h">540<span id="cmdoption-gzip-help"></span><span class="sig-name descname"><span class="pre">-h</span></span><span class="sig-prename descclassname"></span><span class="sig-prename descclassname"><span class="pre">,</span> </span><span class="sig-name descname"><span class="pre">--help</span></span><span class="sig-prename descclassname"></span><a class="headerlink" href="#cmdoption-gzip-h" title="Link to this definition">¶</a></dt>541<dd><p>Show the help message.</p>542</dd></dl>543 544</section>545</section>546</section>547 548 549 <div class="clearer"></div>550 </div>551 </div>552 </div>553 <div class="sphinxsidebar" role="navigation" aria-label="Main">554 <div class="sphinxsidebarwrapper">555 <div>556 <h3><a href="../contents.html">Table of Contents</a></h3>557 <ul>558<li><a class="reference internal" href="#"><code class="xref py py-mod docutils literal notranslate"><span class="pre">gzip</span></code> — Support for <strong class="program">gzip</strong> files</a><ul>559<li><a class="reference internal" href="#examples-of-usage">Examples of usage</a></li>560<li><a class="reference internal" href="#command-line-interface">Command-line interface</a><ul>561<li><a class="reference internal" href="#command-line-options">Command-line options</a></li>562</ul>563</li>564</ul>565</li>566</ul>567 568 </div>569 <div>570 <h4>Previous topic</h4>571 <p class="topless"><a href="zlib.html"572 title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">zlib</span></code> — Compression compatible with <strong class="program">gzip</strong></a></p>573 </div>574 <div>575 <h4>Next topic</h4>576 <p class="topless"><a href="bz2.html"577 title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">bz2</span></code> — Support for <strong class="program">bzip2</strong> compression</a></p>578 </div>579 <script>580 document.addEventListener('DOMContentLoaded', () => {581 const title = document.querySelector('meta[property="og:title"]').content;582 const elements = document.querySelectorAll('.improvepage');583 const pageurl = window.location.href.split('?')[0];584 elements.forEach(element => {585 const url = new URL(element.href.split('?')[0].replace("-nojs", ""));586 url.searchParams.set('pagetitle', title);587 url.searchParams.set('pageurl', pageurl);588 url.searchParams.set('pagesource', "library/gzip.rst");589 element.href = url.toString();590 });591 });592 </script>593 <div role="note" aria-label="source link">594 <h3>This page</h3>595 <ul class="this-page-menu">596 <li><a href="../bugs.html">Report a bug</a></li>597 <li><a class="improvepage" href="../improve-page-nojs.html">Improve this page</a></li>598 <li>599 <a href="https://github.com/python/cpython/blob/main/Doc/library/gzip.rst?plain=1"600 rel="nofollow">Show source601 </a>602 </li>603 604 </ul>605 </div>606 </div>607<div id="sidebarbutton" title="Collapse sidebar">608<span>«</span>609</div>610 611 </div>612 <div class="clearer"></div>613 </div> 614 <div class="related" role="navigation" aria-label="Related">615 <h3>Navigation</h3>616 <ul>617 <li class="right" style="margin-right: 10px">618 <a href="../genindex.html" title="General Index"619 >index</a></li>620 <li class="right" >621 <a href="../py-modindex.html" title="Python Module Index"622 >modules</a> |</li>623 <li class="right" >624 <a href="bz2.html" title="bz2 — Support for bzip2 compression"625 >next</a> |</li>626 <li class="right" >627 <a href="zlib.html" title="zlib — Compression compatible with gzip"628 >previous</a> |</li>629 630 <li><img src="../_static/py.svg" alt="Python logo" style="vertical-align: middle; margin-top: -1px"></li>631 <li><a href="https://www.python.org/">Python</a> »</li>632 <li class="switchers">633 <div class="language_switcher_placeholder"></div>634 <div class="version_switcher_placeholder"></div>635 </li>636 <li>637 638 </li>639 <li id="cpython-language-and-version">640 <a href="../index.html">3.15.0a6 Documentation</a> »641 </li>642 643 <li class="nav-item nav-item-1"><a href="index.html" >The Python Standard Library</a> »</li>644 <li class="nav-item nav-item-2"><a href="archiving.html" >Data Compression and Archiving</a> »</li>645 <li class="nav-item nav-item-this"><a href=""><code class="xref py py-mod docutils literal notranslate"><span class="pre">gzip</span></code> — Support for <strong class="program">gzip</strong> files</a></li>646 <li class="right">647 648 649 <div class="inline-search" role="search">650 <form class="inline-search" action="../search.html" method="get">651 <input placeholder="Quick search" aria-label="Quick search" type="search" name="q" id="search-box">652 <input type="submit" value="Go">653 </form>654 </div>655 |656 </li>657 <li class="right">658<label class="theme-selector-label">659 Theme660 <select class="theme-selector" oninput="activateTheme(this.value)">661 <option value="auto" selected>Auto</option>662 <option value="light">Light</option>663 <option value="dark">Dark</option>664 </select>665</label> |</li>666 667 </ul>668 </div> 669 <div class="footer">670 © <a href="../copyright.html">Copyright</a> 2001 Python Software Foundation.671 <br>672 This page is licensed under the Python Software Foundation License Version 2.673 <br>674 Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.675 <br>676 677 See <a href="/license.html">History and License</a> for more information.<br>678 679 680 <br>681 682 The Python Software Foundation is a non-profit corporation.683<a href="https://www.python.org/psf/donations/">Please donate.</a>684<br>685 <br>686 Last updated on Mar 10, 2026 (08:58 UTC).687 688 <a href="/bugs.html">Found a bug</a>?689 690 <br>691 692 Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 8.2.3.693 </div>694 695 </body>696</html>