* **Potential problem with cache is that it can grow indefinitely. To clear the cache run `'fib.cache_clear()'` or use `'@functools.lru_cache(maxsize=<int>)'` instead.**
* **Potential problem with cache is that it can grow indefinitely. To clear its stored values run `'fib.cache_clear()'`, or use `'@lru_cache(maxsize=<int>)'` decorator instead.**
* **CPython interpreter limits recursion depth to 3000 by default. To increase it run `'sys.setrecursionlimit(<int>)'`.**
### Parametrized Decorator
@ -1937,14 +1937,14 @@ with <conn>.begin(): ... # Exits the block with commit or
@ -776,7 +776,7 @@ player = Player(point, direction) <span class="hljs-comment">#
<ul>
<li><strong>Potential problem with cache is that it can grow indefinitely. To clear the cache run <codeclass="python hljs"><spanclass="hljs-string">'fib.cache_clear()'</span></code> or use <codeclass="python hljs"><spanclass="hljs-string">'@functools.lru_cache(maxsize=<int>)'</span></code> instead.</strong></li>
<li><strong>Potential problem with cache is that it can grow indefinitely. To clear its stored values run <codeclass="python hljs"><spanclass="hljs-string">'fib.cache_clear()'</span></code>, or use <codeclass="python hljs"><spanclass="hljs-string">'@lru_cache(maxsize=<int>)'</span></code> decorator instead.</strong></li>
<li><strong>CPython interpreter limits recursion depth to 3000 by default. To increase it run <codeclass="python hljs"><spanclass="hljs-string">'sys.setrecursionlimit(<int>)'</span></code>.</strong></li>
</ul>
<div><h3id="parametrizeddecorator">Parametrized Decorator</h3><p><strong>A decorator that accepts arguments and returns a normal decorator that accepts a function.</strong></p><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">from</span> functools <spanclass="hljs-keyword">import</span> wraps
<div><h2id="bytes"><ahref="#bytes"name="bytes">#</a>Bytes</h2><p><strong>A bytes object is an immutable sequence of single bytes. Mutable version is called bytearray.</strong></p><pre><codeclass="python language-python hljs"><bytes> = <spanclass="hljs-string">b'<str>'</span><spanclass="hljs-comment"># Only accepts ASCII characters and \x00-\xff.</span>
<int> = <bytes>[index] <spanclass="hljs-comment"># Returns an int in range from 0 to 255.</span>
<div><h4id="xpathalsoavailableinlxmlscrapyandbrowsersconsoleviadxxpath">XPath — also available in lxml, Scrapy, and browser's console via <codeclass="python hljs"><spanclass="hljs-string">'$x(<xpath>)'</span></code>:</h4><pre><codeclass="python language-python hljs"><xpath> = //<element>[/ <spanclass="hljs-keyword">or</span> // <element>] <spanclass="hljs-comment"># /<child>, //<descendant>, /../<siblng></span>
<div><h4id="xpathalsoavailableinlxmlscrapyandbrowsersconsoleviadxxpath">XPath — also available in lxml, Scrapy, and browser's console via <codeclass="python hljs"><spanclass="hljs-string">'$x("<xpath>")'</span></code>:</h4><pre><codeclass="python language-python hljs"><xpath> = //<element>[/ <spanclass="hljs-keyword">or</span> // <element>] <spanclass="hljs-comment"># /<child>, //<descendant>, /../<siblng></span>
<xpath> = //<element>/following::<element><spanclass="hljs-comment"># Next element. Also preceding/parent/…</span>
<condition> = [<sub_cond> [<spanclass="hljs-keyword">and</span>/<spanclass="hljs-keyword">or</span><sub_cond>]] <spanclass="hljs-comment"># For negation use `not(<sub_cond>)`.</span>
<li><strong>Use <codeclass="python hljs"><spanclass="hljs-string">'render_template(filename, <kwargs>)'</span></code> to render file located in templates dir.</strong></li>
<li><strong>To return an error code use <codeclass="python hljs"><spanclass="hljs-string">'abort(<int>)'</span></code> and to redirect use <codeclass="python hljs"><spanclass="hljs-string">'redirect("<url>")'</span></code>.</strong></li>
<li><strong>To return an error code use <codeclass="python hljs"><spanclass="hljs-string">'abort(<int>)'</span></code> and to redirect use <codeclass="python hljs"><spanclass="hljs-string">'redirect(<url>)'</span></code>.</strong></li>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'request.args[<str>]'</span></code> returns parameter from the query string (URL part after '?').</strong></li>