|
54 | 54 |
|
55 | 55 | <body>
|
56 | 56 | <header>
|
57 |
| - <aside>July 31, 2023</aside> |
| 57 | + <aside>August 1, 2023</aside> |
58 | 58 | <a href="https://gto76.github.io" rel="author">Jure Šorn</a>
|
59 | 59 | </header>
|
60 | 60 |
|
@@ -1805,9 +1805,9 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
|
1805 | 1805 | <li><strong>Bitwise operators require objects to have and(), or() and xor() special methods, unlike logical operators that work on all types of objects.</strong></li>
|
1806 | 1806 | <li><strong>Also: <code class="python hljs"><span class="hljs-string">'<bool> = <bool> &|^ <bool>'</span></code> and <code class="python hljs"><span class="hljs-string">'<int> = <bool> &|^ <int>'</span></code>.</strong></li>
|
1807 | 1807 | </ul>
|
1808 |
| -<div><h2 id="introspection"><a href="#introspection" name="introspection">#</a>Introspection</h2><pre><code class="python language-python hljs"><list> = dir() <span class="hljs-comment"># Names of local variables (incl. functions).</span> |
1809 |
| -<dict> = vars() <span class="hljs-comment"># Dict of local variables. Also locals().</span> |
1810 |
| -<dict> = globals() <span class="hljs-comment"># Dict of global variables.</span> |
| 1808 | +<div><h2 id="introspection"><a href="#introspection" name="introspection">#</a>Introspection</h2><pre><code class="python language-python hljs"><list> = dir() <span class="hljs-comment"># Names of local variables, functions, classes, etc.</span> |
| 1809 | +<dict> = vars() <span class="hljs-comment"># Dict of local variables, etc. Also locals().</span> |
| 1810 | +<dict> = globals() <span class="hljs-comment"># Dict of global vars, etc. (incl. '__builtins__').</span> |
1811 | 1811 | </code></pre></div>
|
1812 | 1812 |
|
1813 | 1813 | <div><h3 id="attributes">Attributes</h3><pre><code class="python language-python hljs"><list> = dir(<object>) <span class="hljs-comment"># Names of object's attributes (incl. methods).</span>
|
@@ -2886,16 +2886,14 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
|
2886 | 2886 | </code></pre>
|
2887 | 2887 | <pre><code class="python language-python hljs">cdef enum <enum_name>: <member_name>, <member_name>, ...
|
2888 | 2888 | </code></pre>
|
2889 |
| -<div><h3 id="pyinstaller">PyInstaller</h3><pre><code class="bash language-bash hljs">$ pip3 install pyinstaller |
2890 |
| -$ pyinstaller script.py <span class="hljs-comment"># Compiles into './dist/script' directory.</span> |
2891 |
| -$ pyinstaller script.py --onefile <span class="hljs-comment"># Compiles into './dist/script' console app.</span> |
2892 |
| -$ pyinstaller script.py --windowed <span class="hljs-comment"># Compiles into './dist/script' windowed app.</span> |
2893 |
| -$ pyinstaller script.py --add-data '<path>:.' <span class="hljs-comment"># Adds file to the root of the executable.</span> |
| 2889 | +<div><h3 id="virtualenvironments">Virtual Environments</h3><p><strong>System for installing libraries directly into project's directory.</strong></p><pre><code class="bash language-bash hljs">$ python3 -m venv <name> <span class="hljs-comment"># Creates virtual environment in current directory.</span> |
| 2890 | +$ <span class="hljs-built_in">source</span> <name>/bin/activate <span class="hljs-comment"># Activates venv. On Windows run `<name>\Scripts\activate`.</span> |
| 2891 | +$ pip3 install <library> <span class="hljs-comment"># Installs the library into active environment.</span> |
| 2892 | +$ python3 <path> <span class="hljs-comment"># Runs the script in active environment. Also `./<path>`.</span> |
| 2893 | +$ deactivate <span class="hljs-comment"># Deactivates virtual environment.</span> |
2894 | 2894 | </code></pre></div>
|
2895 | 2895 |
|
2896 |
| -<ul> |
2897 |
| -<li><strong>File paths need to be updated to <code class="python hljs"><span class="hljs-string">'os.path.join(sys._MEIPASS, <path>)'</span></code>.</strong></li> |
2898 |
| -</ul> |
| 2896 | + |
2899 | 2897 | <div><h3 id="basicscripttemplate">Basic Script Template</h3><pre><code class="python language-python hljs"><span class="hljs-comment">#!/usr/bin/env python3</span>
|
2900 | 2898 | <span class="hljs-comment">#</span>
|
2901 | 2899 | <span class="hljs-comment"># Usage: .py</span>
|
@@ -2932,7 +2930,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
|
2932 | 2930 |
|
2933 | 2931 |
|
2934 | 2932 | <footer>
|
2935 |
| - <aside>July 31, 2023</aside> |
| 2933 | + <aside>August 1, 2023</aside> |
2936 | 2934 | <a href="https://gto76.github.io" rel="author">Jure Šorn</a>
|
2937 | 2935 | </footer>
|
2938 | 2936 |
|
|
0 commit comments