Skip to content

Commit edf82f8

Browse files
committed
Datetime, Duck types
1 parent 28fb7b1 commit edf82f8

File tree

5 files changed

+8
-9
lines changed

5 files changed

+8
-9
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ from itertools import product, combinations, combinations_with_replacement, perm
584584
Datetime
585585
--------
586586
* **Module 'datetime' provides 'date' `<D>`, 'time' `<T>`, 'datetime' `<DT>` and 'timedelta' `<TD>` classes. All are immutable and hashable.**
587-
* **Time and datetime can be 'aware' `<a>`, meaning they have defined timezone, or 'naive' `<n>`, meaning they don't.**
587+
* **Time and datetime objects can be 'aware' `<a>`, meaning they have defined timezone, or 'naive' `<n>`, meaning they don't.**
588588
* **If object is naive, it is presumed to be in the system's timezone.**
589589

590590
```python
@@ -1259,7 +1259,7 @@ class MySequence:
12591259
### Collections.abc.Sequence
12601260
* **It's a richer interface than the basic sequence.**
12611261
* **Extending it generates iter(), contains(), reversed(), index(), and count().**
1262-
* **Unlike `'abc.Iterable'` and `'abc.Collection'`, it is not a duck type. That is why `'issubclass(MySequence, collections.abc.Sequence)'` would return False even if MySequence had all the methods defined.**
1262+
* **Unlike `'abc.Iterable'` and `'abc.Collection'`, it is not a duck type. That is why `'issubclass(MySequence, abc.Sequence)'` would return False even if MySequence had all the methods defined.**
12631263
```python
12641264
from collections import abc
12651265

@@ -2112,7 +2112,6 @@ setattr(<object>, '<attr_name>', value)
21122112
delattr(<object>, '<attr_name>')
21132113
```
21142114

2115-
21162115
### Parameters
21172116
```python
21182117
from inspect import signature

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@
639639
</code></pre>
640640
<div><h2 id="datetime"><a href="#datetime" name="datetime">#</a>Datetime</h2><ul>
641641
<li><strong>Module 'datetime' provides 'date' <code class="apache hljs"><span class="hljs-section">&lt;D&gt;</span></code>, 'time' <code class="apache hljs"><span class="hljs-section">&lt;T&gt;</span></code>, 'datetime' <code class="apache hljs"><span class="hljs-section">&lt;DT&gt;</span></code> and 'timedelta' <code class="apache hljs"><span class="hljs-section">&lt;TD&gt;</span></code> classes. All are immutable and hashable.</strong></li>
642-
<li><strong>Time and datetime can be 'aware' <code class="apache hljs"><span class="hljs-section">&lt;a&gt;</span></code>, meaning they have defined timezone, or 'naive' <code class="apache hljs"><span class="hljs-section">&lt;n&gt;</span></code>, meaning they don't.</strong></li>
642+
<li><strong>Time and datetime objects can be 'aware' <code class="apache hljs"><span class="hljs-section">&lt;a&gt;</span></code>, meaning they have defined timezone, or 'naive' <code class="apache hljs"><span class="hljs-section">&lt;n&gt;</span></code>, meaning they don't.</strong></li>
643643
<li><strong>If object is naive, it is presumed to be in the system's timezone.</strong></li>
644644
</ul><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> datetime <span class="hljs-keyword">import</span> date, time, datetime, timedelta
645645
<span class="hljs-keyword">from</span> dateutil.tz <span class="hljs-keyword">import</span> UTC, tzlocal, gettz, resolve_imaginary
@@ -1194,7 +1194,7 @@
11941194
<div><h3 id="collectionsabcsequence">Collections.abc.Sequence</h3><ul>
11951195
<li><strong>It's a richer interface than the basic sequence.</strong></li>
11961196
<li><strong>Extending it generates iter(), contains(), reversed(), index(), and count().</strong></li>
1197-
<li><strong>Unlike <code class="python hljs"><span class="hljs-string">'abc.Iterable'</span></code> and <code class="python hljs"><span class="hljs-string">'abc.Collection'</span></code>, it is not a duck type. That is why <code class="python hljs"><span class="hljs-string">'issubclass(MySequence, collections.abc.Sequence)'</span></code> would return False even if MySequence had all the methods defined.</strong></li>
1197+
<li><strong>Unlike <code class="python hljs"><span class="hljs-string">'abc.Iterable'</span></code> and <code class="python hljs"><span class="hljs-string">'abc.Collection'</span></code>, it is not a duck type. That is why <code class="python hljs"><span class="hljs-string">'issubclass(MySequence, abc.Sequence)'</span></code> would return False even if MySequence had all the methods defined.</strong></li>
11981198
</ul><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> collections <span class="hljs-keyword">import</span> abc
11991199

12001200
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyAbcSequence</span><span class="hljs-params">(abc.Sequence)</span>:</span>

web/index_for_pdf.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ <h3 id="c">C</h3>
3737
<strong>csv module, <a href="#csv">26</a>, <a href="#printsacsvfileasanasciitable">34</a></strong><br>
3838
<strong>curses module, <a href="#curses">34</a></strong> </p>
3939
<h3 id="d">D</h3>
40-
<p><strong>dataclasses module, <a href="#dataclass">15</a></strong><br>
40+
<p><strong>dataclasses module, <a href="#namedtupleenumdataclass">12</a></strong>, <a href="#dataclass">15</a></strong><br>
4141
<strong>datetime module, <a href="#datetime">8</a>-<a href="#constructors">9</a></strong><br>
4242
<strong>decorator, <a href="#decorator">13</a></strong><br>
4343
<strong>deques, <a href="#deque">29</a></strong><br>

web/index_for_pdf_print.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ <h3 id="c">C</h3>
4141
<strong>csv module, 26, 34</strong><br>
4242
<strong>curses module, 34</strong> </p>
4343
<h3 id="d">D</h3>
44-
<p><strong>dataclasses module, 15</strong><br>
44+
<p><strong>dataclasses module, 12, 15</strong><br>
4545
<strong>datetime module, 8-9</strong><br>
4646
<strong>decorator, 13</strong><br>
4747
<strong>deques, 29</strong><br>

web/script_2.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,9 @@ const DIAGRAM_8_B =
173173
" │ └── ZeroDivisionError <span class='hljs-comment'># Raised when dividing by zero.</span>\n" +
174174
" ├── AttributeError <span class='hljs-comment'># Raised when an attribute is missing.</span>\n" +
175175
" ├── EOFError <span class='hljs-comment'># Raised by input() when it hits end-of-file condition.</span>\n" +
176-
" ├── LookupError <span class='hljs-comment'># Raised when a look-up on a sequence or dict fails.</span>\n" +
176+
" ├── LookupError <span class='hljs-comment'># Raised when a look-up on a collection fails.</span>\n" +
177177
" │ ├── IndexError <span class='hljs-comment'># Raised when a sequence index is out of range.</span>\n" +
178-
" │ └── KeyError <span class='hljs-comment'># Raised when a dictionary key is not found.</span>\n" +
178+
" │ └── KeyError <span class='hljs-comment'># Raised when a dictionary key or set element is not found.</span>\n" +
179179
" ├── NameError <span class='hljs-comment'># Raised when a variable name is not found.</span>\n" +
180180
" ├── OSError <span class='hljs-comment'># Failures such as “file not found” or “disk full”.</span>\n" +
181181
" │ └── FileNotFoundError <span class='hljs-comment'># When a file or directory is requested but doesn't exist.</span>\n" +

0 commit comments

Comments
 (0)