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

Skip to content

Commit e65b871

Browse files
committed
Datetime, Class, Coroutines
1 parent dc87ae2 commit e65b871

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -643,11 +643,11 @@ from dateutil.tz import UTC, tzlocal, gettz, datetime_exists, resolve_imaginary
643643

644644
### Format
645645
```python
646-
>>> dt = datetime.strptime('2015-05-14 23:39:00.00 +0200', '%Y-%m-%d %H:%M:%S.%f %z')
646+
>>> dt = datetime.strptime('2015-05-14 23:39:00.00 +02:00', '%Y-%m-%d %H:%M:%S.%f %z')
647647
>>> dt.strftime("%A, %dth of %B '%y, %I:%M%p %Z")
648648
"Thursday, 14th of May '15, 11:39PM UTC+02:00"
649649
```
650-
* **`'%Z'` only accepts `'UTC/GMT'` and local timezone's code. `'%z'` also accepts `HH:MM'`.**
650+
* **`'%Z'` only accepts `'UTC/GMT'` and local timezone's code. `'%z'` also accepts `HHMM'`.**
651651
* **For abbreviated weekday and month use `'%a'` and `'%b'`.**
652652

653653
### Arithmetics
@@ -964,18 +964,18 @@ class <name>:
964964
#### Str() use cases:
965965
```python
966966
print(<el>)
967-
print(f'{<el>}')
968-
raise Exception(<el>)
969-
csv.writer(<file>).writerow([<el>])
967+
f'{<el>}'
970968
logging.warning(<el>)
969+
csv.writer(<file>).writerow([<el>])
970+
raise Exception(<el>)
971971
```
972972

973973
#### Repr() use cases:
974974
```python
975975
print([<el>])
976-
print(f'{<el>!r}')
977-
>>> <el>
976+
f'{<el>!r}'
978977
Z = dataclasses.make_dataclass('Z', ['a']); print(Z(<el>))
978+
>>> <el>
979979
```
980980

981981
### Constructor Overloading
@@ -2327,7 +2327,7 @@ async def random_controller(id_, moves):
23272327
async def human_controller(screen, moves):
23282328
while True:
23292329
ch = screen.getch()
2330-
key_mappings = {259: D.n, 261: D.e, 258: D.s, 260: D.w}
2330+
key_mappings = {258: D.s, 259: D.n, 260: D.w, 261: D.e}
23312331
if ch in key_mappings:
23322332
moves.put_nowait(('*', key_mappings[ch]))
23332333
await asyncio.sleep(0.005)

index.html

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

5555
<body>
5656
<header>
57-
<aside>January 26, 2022</aside>
57+
<aside>January 27, 2022</aside>
5858
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
5959
</header>
6060

@@ -570,13 +570,13 @@
570570
&lt;float&gt; = &lt;DTa&gt;.timestamp() <span class="hljs-comment"># Seconds since the Epoch, from DTa.</span>
571571
</code></pre></div>
572572

573-
<div><h3 id="format-1">Format</h3><pre><code class="python language-python hljs"><span class="hljs-meta">&gt;&gt;&gt; </span>dt = datetime.strptime(<span class="hljs-string">'2015-05-14 23:39:00.00 +0200'</span>, <span class="hljs-string">'%Y-%m-%d %H:%M:%S.%f %z'</span>)
573+
<div><h3 id="format-1">Format</h3><pre><code class="python language-python hljs"><span class="hljs-meta">&gt;&gt;&gt; </span>dt = datetime.strptime(<span class="hljs-string">'2015-05-14 23:39:00.00 +02:00'</span>, <span class="hljs-string">'%Y-%m-%d %H:%M:%S.%f %z'</span>)
574574
<span class="hljs-meta">&gt;&gt;&gt; </span>dt.strftime(<span class="hljs-string">"%A, %dth of %B '%y, %I:%M%p %Z"</span>)
575575
<span class="hljs-string">"Thursday, 14th of May '15, 11:39PM UTC+02:00"</span>
576576
</code></pre></div>
577577

578578
<ul>
579-
<li><strong><code class="python hljs"><span class="hljs-string">'%Z'</span></code> only accepts <code class="python hljs"><span class="hljs-string">'UTC/GMT'</span></code> and local timezone's code. <code class="python hljs"><span class="hljs-string">'%z'</span></code> also accepts <code class="python hljs"><span class="hljs-string">HH:MM'</span></code>.</strong></li>
579+
<li><strong><code class="python hljs"><span class="hljs-string">'%Z'</span></code> only accepts <code class="python hljs"><span class="hljs-string">'UTC/GMT'</span></code> and local timezone's code. <code class="python hljs"><span class="hljs-string">'%z'</span></code> also accepts <code class="python hljs"><span class="hljs-string">HHMM'</span></code>.</strong></li>
580580
<li><strong>For abbreviated weekday and month use <code class="python hljs"><span class="hljs-string">'%a'</span></code> and <code class="python hljs"><span class="hljs-string">'%b'</span></code>.</strong></li>
581581
</ul>
582582
<div><h3 id="arithmetics">Arithmetics</h3><pre><code class="python language-python apache hljs">&lt;D/DT&gt; = &lt;D/DT&gt; ± &lt;TD&gt; <span class="hljs-comment"># Returned datetime can fall into missing hour.</span>
@@ -821,16 +821,16 @@
821821
<li><strong>If only repr() is defined, it will also be used for str().</strong></li>
822822
</ul>
823823
<div><h4 id="strusecases">Str() use cases:</h4><pre><code class="python language-python hljs">print(&lt;el&gt;)
824-
print(<span class="hljs-string">f'<span class="hljs-subst">{&lt;el&gt;}</span>'</span>)
825-
<span class="hljs-keyword">raise</span> Exception(&lt;el&gt;)
826-
csv.writer(&lt;file&gt;).writerow([&lt;el&gt;])
824+
<span class="hljs-string">f'<span class="hljs-subst">{&lt;el&gt;}</span>'</span>
827825
logging.warning(&lt;el&gt;)
826+
csv.writer(&lt;file&gt;).writerow([&lt;el&gt;])
827+
<span class="hljs-keyword">raise</span> Exception(&lt;el&gt;)
828828
</code></pre></div>
829829

830830
<div><h4 id="reprusecases">Repr() use cases:</h4><pre><code class="python language-python hljs">print([&lt;el&gt;])
831-
print(<span class="hljs-string">f'<span class="hljs-subst">{&lt;el&gt;!r}</span>'</span>)
832-
<span class="hljs-meta">&gt;&gt;&gt; </span>&lt;el&gt;
831+
<span class="hljs-string">f'<span class="hljs-subst">{&lt;el&gt;!r}</span>'</span>
833832
Z = dataclasses.make_dataclass(<span class="hljs-string">'Z'</span>, [<span class="hljs-string">'a'</span>]); print(Z(&lt;el&gt;))
833+
<span class="hljs-meta">&gt;&gt;&gt; </span>&lt;el&gt;
834834
</code></pre></div>
835835

836836
<div><h3 id="constructoroverloading">Constructor Overloading</h3><pre><code class="python language-python hljs"><span class="hljs-class"><span class="hljs-keyword">class</span> &lt;<span class="hljs-title">name</span>&gt;:</span>
@@ -1903,7 +1903,7 @@
19031903
<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">human_controller</span><span class="hljs-params">(screen, moves)</span>:</span>
19041904
<span class="hljs-keyword">while</span> <span class="hljs-keyword">True</span>:
19051905
ch = screen.getch()
1906-
key_mappings = {<span class="hljs-number">259</span>: D.n, <span class="hljs-number">261</span>: D.e, <span class="hljs-number">258</span>: D.s, <span class="hljs-number">260</span>: D.w}
1906+
key_mappings = {<span class="hljs-number">258</span>: D.s, <span class="hljs-number">259</span>: D.n, <span class="hljs-number">260</span>: D.w, <span class="hljs-number">261</span>: D.e}
19071907
<span class="hljs-keyword">if</span> ch <span class="hljs-keyword">in</span> key_mappings:
19081908
moves.put_nowait((<span class="hljs-string">'*'</span>, key_mappings[ch]))
19091909
<span class="hljs-keyword">await</span> asyncio.sleep(<span class="hljs-number">0.005</span>)
@@ -2881,7 +2881,7 @@
28812881

28822882

28832883
<footer>
2884-
<aside>January 26, 2022</aside>
2884+
<aside>January 27, 2022</aside>
28852885
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
28862886
</footer>
28872887

0 commit comments

Comments
 (0)