<pre><codeclass="python language-python hljs"><bool> = <sub_str><spanclass="hljs-keyword">in</span><str><spanclass="hljs-comment"># Checks if string contains the substring.</span>
<bool> = <str>.startswith(<sub_str>) <spanclass="hljs-comment"># Pass tuple of strings for multiple options.</span>
<int> = <str>.find(<sub_str>) <spanclass="hljs-comment"># Returns start index of the first match or -1.</span>
<int> = <str>.index(<sub_str>) <spanclass="hljs-comment"># Same, but raises ValueError if there's no match.</span>
</code></pre>
<pre><codeclass="python language-python hljs"><str> = <str>.lower() <spanclass="hljs-comment"># Changes the case. Also upper/capitalize/title().</span>
<pre><codeclass="python language-python hljs"><str> = <str>.lower() <spanclass="hljs-comment"># Lowers the case. Also upper/capitalize/title().</span>
<str> = <str>.casefold() <spanclass="hljs-comment"># Same, but converts ẞ/ß to ss, Σ/ς to σ, etc.</span>
<str> = <str>.replace(old, new [, count]) <spanclass="hljs-comment"># Replaces 'old' with 'new' at most 'count' times.</span>
<str> = <str>.translate(<table>) <spanclass="hljs-comment"># Use `str.maketrans(<dict>)` to generate table.</span>
</code></pre>
@ -2288,7 +2288,7 @@ right = np.array([[<span class="hljs-number">0.1</span>, <span class="hljs-numb
<div><h3id="modes-1">Modes</h3><ul>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'L'</span></code> - Lightness (greyscale image). Each pixel is an integer between 0 and 255.</strong></li>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'RGB'</span></code> - Red, green, blue (true color image). Each pixel is a tuple of three integers.</strong></li>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'RGBA'</span></code> - RGB with alpha. Low alpha (i.e. forth int) makes pixel more transparent.</strong></li>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'RGBA'</span></code> - RGB with alpha. Low alpha (i.e. fourth int) makes pixel more transparent.</strong></li>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'HSV'</span></code> - Hue, saturation, value. Three ints representing color in HSV color space.</strong></li>
</ul><div><h3id="examples">Examples</h3><div><h4id="createsapngimageofarainbowgradient">Creates a PNG image of a rainbow gradient:</h4><pre><codeclass="python language-python hljs">WIDTH, HEIGHT = <spanclass="hljs-number">100</span>, <spanclass="hljs-number">100</span>
<Fig>.update_layout(paper_bgcolor=<spanclass="hljs-string">'rgb(0, 0, 0)'</span>) <spanclass="hljs-comment"># Also `margin=dict(t=0, r=0, b=0, l=0)`.</span>
<Fig>.update_layout(paper_bgcolor=<spanclass="hljs-string">'#rrggbb'</span>)<spanclass="hljs-comment"># Also `margin=dict(t=0, r=0, b=0, l=0)`.</span>
<Fig>.write_html/json/image(<spanclass="hljs-string">'<path>'</span>) <spanclass="hljs-comment"># Use <Fig>.show() to display the plot.</span>
</code></pre>
<pre><codeclass="python language-python hljs"><Fig> = px.area/bar/box(<DF>, x=col_key, y=col_keys) <spanclass="hljs-comment"># Also `color=col_key`. All are optional.</span>
<li><strong>All <codeclass="python hljs"><spanclass="hljs-string">'cdef'</span></code> definitions are optional, but they contribute to the speed-up.</strong></li>
<li><strong>Also supports C pointers (via <codeclass="python hljs"><spanclass="hljs-string">'*'</span></code> and <codeclass="python hljs"><spanclass="hljs-string">'&'</span></code>), structs, unions and enums.</strong></li>
<div><h4id="allcdefdefinitionsareoptionalbuttheycontributetothespeedup">All <codeclass="python hljs"><spanclass="hljs-string">'cdef'</span></code> definitions are optional, but they contribute to the speed-up:</h4><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">cdef</span><ctype/type> [*]<var_name> [= <obj>]
<div><h3id="virtualenvironments">Virtual Environments</h3><p><strong>System for installing libraries directly into project's directory.</strong></p><pre><codeclass="python hljs">$ python3 -m venv NAME <spanclass="hljs-comment"># Creates virtual environment in current directory.</span>
$ source NAME/bin/activate <spanclass="hljs-comment"># Activates it. On Windows run `NAME\Scripts\activate`.</span>
@ -2940,7 +2939,7 @@ $ deactivate <span class="hljs-comment"># Deactivates the active