Browse Source

Datetime, Duck types

pull/46/head
Jure Šorn 4 years ago
parent
commit
edf82f8179
5 changed files with 8 additions and 9 deletions
  1. 5
      README.md
  2. 4
      index.html
  3. 2
      web/index_for_pdf.html
  4. 2
      web/index_for_pdf_print.html
  5. 4
      web/script_2.js

5
README.md

@ -584,7 +584,7 @@ from itertools import product, combinations, combinations_with_replacement, perm
Datetime
--------
* **Module 'datetime' provides 'date' `<D>`, 'time' `<T>`, 'datetime' `<DT>` and 'timedelta' `<TD>` classes. All are immutable and hashable.**
* **Time and datetime can be 'aware' `<a>`, meaning they have defined timezone, or 'naive' `<n>`, meaning they don't.**
* **Time and datetime objects can be 'aware' `<a>`, meaning they have defined timezone, or 'naive' `<n>`, meaning they don't.**
* **If object is naive, it is presumed to be in the system's timezone.**
```python
@ -1259,7 +1259,7 @@ class MySequence:
### Collections.abc.Sequence
* **It's a richer interface than the basic sequence.**
* **Extending it generates iter(), contains(), reversed(), index(), and count().**
* **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.**
* **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.**
```python
from collections import abc
@ -2112,7 +2112,6 @@ setattr(<object>, '<attr_name>', value)
delattr(<object>, '<attr_name>')
```
### Parameters
```python
from inspect import signature

4
index.html

@ -639,7 +639,7 @@ shuffle(&lt;list&gt;)
</code></pre>
<div><h2 id="datetime"><a href="#datetime" name="datetime">#</a>Datetime</h2><ul>
<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>
<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>
<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>
<li><strong>If object is naive, it is presumed to be in the system's timezone.</strong></li>
</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
<span class="hljs-keyword">from</span> dateutil.tz <span class="hljs-keyword">import</span> UTC, tzlocal, gettz, resolve_imaginary
@ -1194,7 +1194,7 @@ Hello World!
<div><h3 id="collectionsabcsequence">Collections.abc.Sequence</h3><ul>
<li><strong>It's a richer interface than the basic sequence.</strong></li>
<li><strong>Extending it generates iter(), contains(), reversed(), index(), and count().</strong></li>
<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>
<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>
</ul><pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> collections <span class="hljs-keyword">import</span> abc
<span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyAbcSequence</span><span class="hljs-params">(abc.Sequence)</span>:</span>

2
web/index_for_pdf.html

@ -37,7 +37,7 @@
<strong>csv module, <a href="#csv">26</a>, <a href="#printsacsvfileasanasciitable">34</a></strong><br>
<strong>curses module, <a href="#curses">34</a></strong> </p>
<h3 id="d">D</h3>
<p><strong>dataclasses module, <a href="#dataclass">15</a></strong><br>
<p><strong>dataclasses module, <a href="#namedtupleenumdataclass">12</a></strong>, <a href="#dataclass">15</a></strong><br>
<strong>datetime module, <a href="#datetime">8</a>-<a href="#constructors">9</a></strong><br>
<strong>decorator, <a href="#decorator">13</a></strong><br>
<strong>deques, <a href="#deque">29</a></strong><br>

2
web/index_for_pdf_print.html

@ -41,7 +41,7 @@
<strong>csv module, 26, 34</strong><br>
<strong>curses module, 34</strong> </p>
<h3 id="d">D</h3>
<p><strong>dataclasses module, 15</strong><br>
<p><strong>dataclasses module, 12, 15</strong><br>
<strong>datetime module, 8-9</strong><br>
<strong>decorator, 13</strong><br>
<strong>deques, 29</strong><br>

4
web/script_2.js

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

Loading…
Cancel
Save