<div><h1id="comprehensivepythoncheatsheet">Comprehensive Python Cheatsheet</h1><pclass="banner"><sup><ahref="https://raw.githubusercontent.com/gto76/python-cheatsheet/master/README.md">Download text file</a>, <ahref="https://transactions.sendowl.com/products/78175486/4422834F/view">Buy PDF</a>, <ahref="https://github.com/gto76/python-cheatsheet">Fork me on GitHub</a> or <ahref="https://github.com/gto76/python-cheatsheet/wiki/Frequently-Asked-Questions">Check out FAQ</a>.
<li><strong>Module <ahref="#operator">operator</a> provides functions itemgetter() and mul() that offer the same functionality as <ahref="#lambda">lambda</a> expressions above.</strong></li>
</ul>
<pre><codeclass="python language-python hljs"><int> = <list>.count(<el>) <spanclass="hljs-comment"># Returns number of occurrences. Also works on strings.</span>
<pre><codeclass="python language-python hljs"><list>.insert(<int>, <el>) <spanclass="hljs-comment"># Inserts item at index and moves the rest to the right.</span>
<el> = <list>.pop([<int>]) <spanclass="hljs-comment"># Returns and removes item at index or from the end.</span>
<int> = <list>.count(<el>) <spanclass="hljs-comment"># Returns number of occurrences. Also works on strings.</span>
<int> = <list>.index(<el>) <spanclass="hljs-comment"># Returns index of the first occurrence or raises ValueError.</span>
<list>.insert(<int>, <el>) <spanclass="hljs-comment"># Inserts item at index and moves the rest to the right.</span>
<el> = <list>.pop([<int>]) <spanclass="hljs-comment"># Removes and returns item at index or from the end.</span>
<list>.remove(<el>) <spanclass="hljs-comment"># Removes first occurrence of the item or raises ValueError.</span>
<list>.clear() <spanclass="hljs-comment"># Removes all items. Also works on dictionary and set.</span>
<div><h2id="introspection"><ahref="#introspection"name="introspection">#</a>Introspection</h2><p><strong>Inspecting code at runtime.</strong></p><div><h3id="variables">Variables</h3><pre><codeclass="python language-python hljs"><list> = dir() <spanclass="hljs-comment"># Names of local variables (incl. functions).</span>
<div><h2id="index"><ahref="#index"name="index">#</a>Index</h2><ul><li><strong>Only available in <ahref="https://transactions.sendowl.com/products/78175486/4422834F/view">PDF</a>.</strong></li>
<div><h2id="index"><ahref="#index"name="index">#</a>Index</h2><ul><li><strong>Only available in the <ahref="https://transactions.sendowl.com/products/78175486/4422834F/view">PDF</a>.</strong></li>
<li><strong>Ctrl+F / ⌘F is usually sufficient.</strong></li>
<li><strong>Searching <codeclass="python hljs"><spanclass="hljs-string">'#<title>'</span></code> will limit the search to the titles.</strong></li>
'$ pyinstaller script.py --add-data \'<path>:.\' <span class="hljs-comment"># Adds file to the root of the executable.</span>\n';
constINDEX=
'<li><strong>Only available in <a href="https://transactions.sendowl.com/products/78175486/4422834F/view">PDF</a>.</strong></li>\n'+
'<li><strong>Only available in the <a href="https://transactions.sendowl.com/products/78175486/4422834F/view">PDF</a>.</strong></li>\n'+
'<li><strong>Ctrl+F / ⌘F is usually sufficient.</strong></li>\n'+
'<li><strong>Searching <code class="python hljs"><span class="hljs-string">\'#<title>\'</span></code> will limit the search to the titles.</strong></li>\n';