Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 34a9943

Browse files
committed
Small changes
1 parent c41c5b2 commit 34a9943

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1870,8 +1870,8 @@ def read_csv_file(filename, dialect='excel', **params):
18701870

18711871
### Write Rows to CSV File
18721872
```python
1873-
def write_to_csv_file(filename, rows, dialect='excel', **params):
1874-
with open(filename, 'w', encoding='utf-8', newline='') as file:
1873+
def write_to_csv_file(filename, rows, mode='w', dialect='excel', **params):
1874+
with open(filename, mode, encoding='utf-8', newline='') as file:
18751875
writer = csv.writer(file, dialect, **params)
18761876
writer.writerows(rows)
18771877
```
@@ -2383,10 +2383,9 @@ Progress Bar
23832383
------------
23842384
```python
23852385
# $ pip3 install tqdm
2386-
>>> from tqdm import tqdm
2387-
>>> from time import sleep
2388-
>>> for el in tqdm([1, 2, 3], desc='Processing'):
2389-
... sleep(1)
2386+
>>> import tqdm, time
2387+
>>> for el in tqdm.tqdm([1, 2, 3], desc='Processing'):
2388+
... time.sleep(1)
23902389
Processing: 100%|████████████████████| 3/3 [00:03<00:00, 1.00s/it]
23912390
```
23922391

@@ -2420,8 +2419,9 @@ print(table)
24202419

24212420
Curses
24222421
------
2423-
#### Runs a basic file explorer in the terminal:
2422+
#### Runs a basic file explorer in the console:
24242423
```python
2424+
# pip3 install windows-curses
24252425
import curses, os
24262426
from curses import A_REVERSE, KEY_DOWN, KEY_UP, KEY_LEFT, KEY_RIGHT, KEY_ENTER
24272427

@@ -2619,7 +2619,7 @@ Line # Hits Time Per Hit % Time Line Contents
26192619
$ pip3 install gprof2dot snakeviz; apt/brew install graphviz
26202620
$ tail -n 4 test.py > test.py
26212621
$ python3 -m cProfile -o test.prof test.py
2622-
$ gprof2dot -f pstats test.prof | dot -Tpng -o test.png; xdg-open/open test.png
2622+
$ gprof2dot -f pstats test.prof | dot -T png -o test.png; xdg-open/open test.png
26232623
$ snakeviz test.prof
26242624
```
26252625

@@ -2778,7 +2778,7 @@ from PIL import Image, ImageFilter, ImageEnhance
27782778
```
27792779

27802780
```python
2781-
<array> = np.array(<Image>) # Creates NumPy array from the image.
2781+
<array> = np.array(<Image>) # Creates a NumPy array from the image.
27822782
<Image> = Image.fromarray(np.uint8(<array>)) # Use <array>.clip(0, 255) to clip values.
27832783
```
27842784

@@ -3240,7 +3240,7 @@ b 3 4
32403240
```python
32413241
<Sr/DF> = <DF>[column_key/s] # Or: <DF>.column_key
32423242
<DF> = <DF>[row_bools] # Keeps rows as specified by bools.
3243-
<DF> = <DF>[<DF_of_bools>] # Assigns NaN to values that are False in bools.
3243+
<DF> = <DF>[<DF_of_bools>] # Assigns NaN to items that are False in bools.
32443244
```
32453245

32463246
```python

index.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
<body>
5656
<header>
57-
<aside>October 11, 2023</aside>
57+
<aside>October 16, 2023</aside>
5858
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
5959
</header>
6060

@@ -1553,8 +1553,8 @@
15531553
<span class="hljs-keyword">return</span> list(csv.reader(file, dialect, **params))
15541554
</code></pre></div>
15551555

1556-
<div><h3 id="writerowstocsvfile">Write Rows to CSV File</h3><pre><code class="python language-python hljs"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">write_to_csv_file</span><span class="hljs-params">(filename, rows, dialect=<span class="hljs-string">'excel'</span>, **params)</span>:</span>
1557-
<span class="hljs-keyword">with</span> open(filename, <span class="hljs-string">'w'</span>, encoding=<span class="hljs-string">'utf-8'</span>, newline=<span class="hljs-string">''</span>) <span class="hljs-keyword">as</span> file:
1556+
<div><h3 id="writerowstocsvfile">Write Rows to CSV File</h3><pre><code class="python language-python hljs"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">write_to_csv_file</span><span class="hljs-params">(filename, rows, mode=<span class="hljs-string">'w'</span>, dialect=<span class="hljs-string">'excel'</span>, **params)</span>:</span>
1557+
<span class="hljs-keyword">with</span> open(filename, mode, encoding=<span class="hljs-string">'utf-8'</span>, newline=<span class="hljs-string">''</span>) <span class="hljs-keyword">as</span> file:
15581558
writer = csv.writer(file, dialect, **params)
15591559
writer.writerows(rows)
15601560
</code></pre></div>
@@ -1979,7 +1979,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
19791979
</code></pre></div></div>
19801980

19811981

1982-
<div><h2 id="curses"><a href="#curses" name="curses">#</a>Curses</h2><div><h4 id="runsabasicfileexplorerintheterminal">Runs a basic file explorer in the terminal:</h4><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> curses, os
1982+
<div><h2 id="curses"><a href="#curses" name="curses">#</a>Curses</h2><div><h4 id="runsabasicfileexplorerintheconsole">Runs a basic file explorer in the console:</h4><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> curses, os
19831983
<span class="hljs-keyword">from</span> curses <span class="hljs-keyword">import</span> A_REVERSE, KEY_DOWN, KEY_UP, KEY_LEFT, KEY_RIGHT, KEY_ENTER
19841984

19851985
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">main</span><span class="hljs-params">(screen)</span>:</span>
@@ -2141,7 +2141,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
21412141
<div><h3 id="callandflamegraphs">Call and Flame Graphs</h3><pre><code class="text language-text">$ pip3 install gprof2dot snakeviz; apt/brew install graphviz
21422142
$ tail -n 4 test.py &gt; test.py
21432143
$ python3 -m cProfile -o test.prof test.py
2144-
$ gprof2dot -f pstats test.prof | dot -Tpng -o test.png; xdg-open/open test.png
2144+
$ gprof2dot -f pstats test.prof | dot -T png -o test.png; xdg-open/open test.png
21452145
$ snakeviz test.prof
21462146
</code></pre></div>
21472147

@@ -2262,7 +2262,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
22622262
<pre><code class="python language-python hljs">&lt;Image&gt; = &lt;Image&gt;.filter(&lt;Filter&gt;) <span class="hljs-comment"># `&lt;Filter&gt; = ImageFilter.&lt;name&gt;([&lt;args&gt;])`</span>
22632263
&lt;Image&gt; = &lt;Enhance&gt;.enhance(&lt;float&gt;) <span class="hljs-comment"># `&lt;Enhance&gt; = ImageEnhance.&lt;name&gt;(&lt;Image&gt;)`</span>
22642264
</code></pre>
2265-
<pre><code class="python language-python hljs">&lt;array&gt; = np.array(&lt;Image&gt;) <span class="hljs-comment"># Creates NumPy array from the image.</span>
2265+
<pre><code class="python language-python hljs">&lt;array&gt; = np.array(&lt;Image&gt;) <span class="hljs-comment"># Creates a NumPy array from the image.</span>
22662266
&lt;Image&gt; = Image.fromarray(np.uint8(&lt;array&gt;)) <span class="hljs-comment"># Use &lt;array&gt;.clip(0, 255) to clip values.</span>
22672267
</code></pre>
22682268
<div><h3 id="modes-1">Modes</h3><ul>
@@ -2638,7 +2638,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
26382638
</code></pre>
26392639
<pre><code class="python language-python hljs">&lt;Sr/DF&gt; = &lt;DF&gt;[column_key/s] <span class="hljs-comment"># Or: &lt;DF&gt;.column_key</span>
26402640
&lt;DF&gt; = &lt;DF&gt;[row_bools] <span class="hljs-comment"># Keeps rows as specified by bools.</span>
2641-
&lt;DF&gt; = &lt;DF&gt;[&lt;DF_of_bools&gt;] <span class="hljs-comment"># Assigns NaN to values that are False in bools.</span>
2641+
&lt;DF&gt; = &lt;DF&gt;[&lt;DF_of_bools&gt;] <span class="hljs-comment"># Assigns NaN to items that are False in bools.</span>
26422642
</code></pre>
26432643
<pre><code class="python language-python hljs">&lt;DF&gt; = &lt;DF&gt; &gt; &lt;el/Sr/DF&gt; <span class="hljs-comment"># Returns DF of bools. Sr is treated as a row.</span>
26442644
&lt;DF&gt; = &lt;DF&gt; + &lt;el/Sr/DF&gt; <span class="hljs-comment"># Items with non-matching keys get value NaN.</span>
@@ -2925,7 +2925,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
29252925

29262926

29272927
<footer>
2928-
<aside>October 11, 2023</aside>
2928+
<aside>October 16, 2023</aside>
29292929
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
29302930
</footer>
29312931

0 commit comments

Comments
 (0)