Skip to content

Commit 6a70b6a

Browse files
committed
Datetime, Function
1 parent 0640e70 commit 6a70b6a

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ import re
374374
* **Argument `'flags=re.IGNORECASE'` can be used with all functions.**
375375
* **Argument `'flags=re.MULTILINE'` makes `'^'` and `'$'` match the start/end of each line.**
376376
* **Argument `'flags=re.DOTALL'` makes `'.'` also accept the `'\n'`.**
377-
* **`'re.compile(<regex>)'` returns a Pattern object with methods sub(), findall(), **
377+
* **`'re.compile(<regex>)'` returns a Pattern object with methods sub(), findall(), etc.**
378378

379379
### Match Object
380380
```python
@@ -500,7 +500,7 @@ Numbers
500500
<Fraction> = fractions.Fraction(0, 1) # Or: Fraction(numerator=0, denominator=1)
501501
<Decimal> = decimal.Decimal(<str/int>) # Or: Decimal((sign, digits, exponent))
502502
```
503-
* **Decimal numbers are stored exactly, unlike most floats where: `'1.1 + 2.2 != 3.3'`.**
503+
* **Decimal numbers are stored exactly, unlike most floats where `'1.1 + 2.2 != 3.3'`.**
504504
* **Floats can be compared with: `'math.isclose(<float>, <float>)'`.**
505505
* **Precision of decimal operations is set with: `'decimal.getcontext().prec = <int>'`.**
506506
* **Bools can be used anywhere ints can, because bool is a subclass of int: `'True + 1 == 2'`.**
@@ -655,8 +655,8 @@ import zoneinfo, dateutil.tz
655655
>>> dt.strftime("%dth of %B '%y (%a), %I:%M %p %Z")
656656
"14th of August '25 (Thu), 11:39 PM UTC+02:00"
657657
```
658-
* **`'%z'` accepts `'±HH[:]MM'` and returns `'±HHMM'` or empty string if datetime is naive.**
659-
* **`'%Z'` accepts `'UTC/GMT'` and local timezone's code and returns timezone's name, `'UTC[±HH:MM]'` if timezone is nameless, or an empty string if datetime is naive.**
658+
* **`'%z'` accepts `'±HH[:]MM'` and returns `'±HHMM'` or empty string if object is naive.**
659+
* **`'%Z'` accepts `'UTC/GMT'` and local timezone's code and returns timezone's name, `'UTC[±HH:MM]'` if timezone is nameless, or an empty string if object is naive.**
660660

661661
### Arithmetics
662662
```python
@@ -679,7 +679,7 @@ def <func_name>(<default_args>): ... # E.g. `def func(x=0, y
679679
def <func_name>(<nondefault_args>, <default_args>): ... # E.g. `def func(x, y=0): ...`.
680680
```
681681
* **Function returns None if it doesn't encounter `'return <obj/exp>'` statement.**
682-
* **Before modifying a global variable from within the function run `'global <var_name>'`.**
682+
* **Run `'global <var_name>'` inside the function before assigning to global variable.**
683683
* **Default values are evaluated when function is first encountered in the scope. Any mutation of a mutable default value will persist between invocations!**
684684

685685
### Function Call

index.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656

5757
<body>
5858
<header>
59-
<aside>March 30, 2025</aside>
59+
<aside>April 1, 2025</aside>
6060
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
6161
</header>
6262

@@ -356,7 +356,7 @@
356356
<li><strong>Argument <code class="python hljs"><span class="hljs-string">'flags=re.IGNORECASE'</span></code> can be used with all functions.</strong></li>
357357
<li><strong>Argument <code class="python hljs"><span class="hljs-string">'flags=re.MULTILINE'</span></code> makes <code class="python hljs"><span class="hljs-string">'^'</span></code> and <code class="python hljs"><span class="hljs-string">'$'</span></code> match the start/end of each line.</strong></li>
358358
<li><strong>Argument <code class="python hljs"><span class="hljs-string">'flags=re.DOTALL'</span></code> makes <code class="python hljs"><span class="hljs-string">'.'</span></code> also accept the <code class="python hljs"><span class="hljs-string">'\n'</span></code>.</strong></li>
359-
<li><strong><code class="python hljs"><span class="hljs-string">'re.compile(&lt;regex&gt;)'</span></code> returns a Pattern object with methods sub(), findall(), </strong></li>
359+
<li><strong><code class="python hljs"><span class="hljs-string">'re.compile(&lt;regex&gt;)'</span></code> returns a Pattern object with methods sub(), findall(), etc.</strong></li>
360360
</ul>
361361
<div><h3 id="matchobject">Match Object</h3><pre><code class="python language-python hljs">&lt;str&gt; = &lt;Match&gt;.group() <span class="hljs-comment"># Returns the whole match. Also group(0).</span>
362362
&lt;str&gt; = &lt;Match&gt;.group(<span class="hljs-number">1</span>) <span class="hljs-comment"># Returns part inside the first brackets.</span>
@@ -463,7 +463,7 @@
463463
</code></pre></div>
464464

465465
<ul>
466-
<li><strong>Decimal numbers are stored exactly, unlike most floats where: <code class="python hljs"><span class="hljs-string">'1.1 + 2.2 != 3.3'</span></code>.</strong></li>
466+
<li><strong>Decimal numbers are stored exactly, unlike most floats where <code class="python hljs"><span class="hljs-string">'1.1 + 2.2 != 3.3'</span></code>.</strong></li>
467467
<li><strong>Floats can be compared with: <code class="python hljs"><span class="hljs-string">'math.isclose(&lt;float&gt;, &lt;float&gt;)'</span></code>.</strong></li>
468468
<li><strong>Precision of decimal operations is set with: <code class="python hljs"><span class="hljs-string">'decimal.getcontext().prec = &lt;int&gt;'</span></code>.</strong></li>
469469
<li><strong>Bools can be used anywhere ints can, because bool is a subclass of int: <code class="python hljs"><span class="hljs-string">'True + 1 == 2'</span></code>.</strong></li>
@@ -585,8 +585,8 @@
585585
</code></pre></div>
586586

587587
<ul>
588-
<li><strong><code class="python hljs"><span class="hljs-string">'%z'</span></code> accepts <code class="python hljs"><span class="hljs-string">'±HH[:]MM'</span></code> and returns <code class="python hljs"><span class="hljs-string">'±HHMM'</span></code> or empty string if datetime is naive.</strong></li>
589-
<li><strong><code class="python hljs"><span class="hljs-string">'%Z'</span></code> accepts <code class="python hljs"><span class="hljs-string">'UTC/GMT'</span></code> and local timezone's code and returns timezone's name, <code class="python hljs"><span class="hljs-string">'UTC[±HH:MM]'</span></code> if timezone is nameless, or an empty string if datetime is naive.</strong></li>
588+
<li><strong><code class="python hljs"><span class="hljs-string">'%z'</span></code> accepts <code class="python hljs"><span class="hljs-string">'±HH[:]MM'</span></code> and returns <code class="python hljs"><span class="hljs-string">'±HHMM'</span></code> or empty string if object is naive.</strong></li>
589+
<li><strong><code class="python hljs"><span class="hljs-string">'%Z'</span></code> accepts <code class="python hljs"><span class="hljs-string">'UTC/GMT'</span></code> and local timezone's code and returns timezone's name, <code class="python hljs"><span class="hljs-string">'UTC[±HH:MM]'</span></code> if timezone is nameless, or an empty string if object is naive.</strong></li>
590590
</ul>
591591
<div><h3 id="arithmetics">Arithmetics</h3><pre><code class="python language-python apache hljs">&lt;bool&gt; = &lt;D/T/DTn&gt; &gt; &lt;D/T/DTn&gt; <span class="hljs-comment"># Ignores time jumps (fold attribute). Also ==.</span>
592592
&lt;bool&gt; = &lt;DTa&gt; &gt; &lt;DTa&gt; <span class="hljs-comment"># Ignores time jumps if they share tzinfo object.</span>
@@ -605,7 +605,7 @@
605605

606606
<ul>
607607
<li><strong>Function returns None if it doesn't encounter <code class="python hljs"><span class="hljs-string">'return &lt;obj/exp&gt;'</span></code> statement.</strong></li>
608-
<li><strong>Before modifying a global variable from within the function run <code class="python hljs"><span class="hljs-string">'global &lt;var_name&gt;'</span></code>.</strong></li>
608+
<li><strong>Run <code class="python hljs"><span class="hljs-string">'global &lt;var_name&gt;'</span></code> inside the function before assigning to global variable.</strong></li>
609609
<li><strong>Default values are evaluated when function is first encountered in the scope. Any mutation of a mutable default value will persist between invocations!</strong></li>
610610
</ul>
611611
<div><h3 id="functioncall">Function Call</h3><pre><code class="python language-python hljs">&lt;obj&gt; = &lt;function&gt;(&lt;positional_args&gt;) <span class="hljs-comment"># E.g. `func(0, 0)`.</span>
@@ -2944,7 +2944,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
29442944

29452945

29462946
<footer>
2947-
<aside>March 30, 2025</aside>
2947+
<aside>April 1, 2025</aside>
29482948
<a href="https://gto76.github.io" rel="author">Jure Šorn</a>
29492949
</footer>
29502950

0 commit comments

Comments
 (0)