Browse Source

Virtual environments, Basic script template

pull/102/merge
Jure Šorn 3 weeks ago
parent
commit
b7fbd03aef
2 changed files with 13 additions and 17 deletions
  1. 15
      README.md
  2. 15
      index.html

15
README.md

@ -3538,22 +3538,19 @@ cdef class <class_name>:
self.<attr_name> = <arg_name>
```
```python
cdef enum <enum_name>: <member_name>, <member_name>, ...
```
### Virtual Environments
**System for installing libraries directly into project's directory.**
```bash
$ python3 -m venv <name> # Creates virtual environment in current directory.
$ source <name>/bin/activate # Activates venv. On Windows run `<name>\Scripts\activate`.
$ pip3 install <library> # Installs the library into active environment.
$ python3 <path> # Runs the script in active environment. Also `./<path>`.
$ deactivate # Deactivates the active virtual environment.
$ python3 -m venv NAME # Creates virtual environment in current directory.
$ source NAME/bin/activate # Activates env. On Windows run `NAME\Scripts\activate`.
$ pip3 install LIBRARY # Installs the library into active environment.
$ python3 FILE # Runs the script in active environment. Also `./FILE`.
$ deactivate # Deactivates the active virtual environment.
```
### Basic Script Template
**Run the script with `'$ python3 FILE'` or `'$ chmod u+x FILE; ./FILE'`. To automatically start the debugger when uncaught exception occurs run `'$ python3 -m pdb -cc FILE'`.**
```python
#!/usr/bin/env python3
#

15
index.html

@ -2886,17 +2886,15 @@ ex.line(df, x=<span class="hljs-string">'Date'</span>, y=<span class="hljs-strin
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span><span class="hljs-params">(self, &lt;ctype&gt; &lt;arg_name&gt;)</span>:</span>
self.&lt;attr_name&gt; = &lt;arg_name&gt;
</code></pre>
<pre><code class="python language-python hljs"><span class="hljs-keyword">cdef</span> <span class="hljs-keyword">enum</span> &lt;enum_name&gt;: &lt;member_name&gt;, &lt;member_name&gt;, ...
</code></pre>
<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 &lt;name&gt; <span class="hljs-comment"># Creates virtual environment in current directory.</span>
$ <span class="hljs-built_in">source</span> &lt;name&gt;/bin/activate <span class="hljs-comment"># Activates venv. On Windows run `&lt;name&gt;\Scripts\activate`.</span>
$ pip3 install &lt;library&gt; <span class="hljs-comment"># Installs the library into active environment.</span>
$ python3 &lt;path&gt; <span class="hljs-comment"># Runs the script in active environment. Also `./&lt;path&gt;`.</span>
$ deactivate <span class="hljs-comment"># Deactivates the active virtual environment.</span>
<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>
$ <span class="hljs-built_in">source</span> NAME/bin/activate <span class="hljs-comment"># Activates env. On Windows run `NAME\Scripts\activate`.</span>
$ pip3 install LIBRARY <span class="hljs-comment"># Installs the library into active environment.</span>
$ python3 FILE <span class="hljs-comment"># Runs the script in active environment. Also `./FILE`.</span>
$ deactivate <span class="hljs-comment"># Deactivates the active virtual environment.</span>
</code></pre></div>
<div><h3 id="basicscripttemplate">Basic Script Template</h3><pre><code class="python language-python hljs"><span class="hljs-comment">#!/usr/bin/env python3</span>
<div><h3 id="basicscripttemplate">Basic Script Template</h3><p><strong>Run the script with <code class="python hljs"><span class="hljs-string">'$ python3 FILE'</span></code> or <code class="python hljs"><span class="hljs-string">'$ chmod u+x FILE; ./FILE'</span></code>. To automatically start the debugger when uncaught exception occurs run <code class="python hljs"><span class="hljs-string">'$ python3 -m pdb -cc FILE'</span></code>.</strong></p><pre><code class="python language-python hljs"><span class="hljs-comment">#!/usr/bin/env python3</span>
<span class="hljs-comment">#</span>
<span class="hljs-comment"># Usage: .py</span>
<span class="hljs-comment">#</span>
@ -2925,6 +2923,7 @@ $ deactivate <span class="hljs-comment"># Deactivates the activ
main()
</code></pre></div>
<div><h2 id="index"><a href="#index" name="index">#</a>Index</h2><ul><li><strong>Only available in the <a href="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 <code class="python hljs"><span class="hljs-string">'#&lt;title&gt;'</span></code> will limit the search to the titles.</strong></li>

Loading…
Cancel
Save