@ -627,8 +627,8 @@ from dateutil.tz import tzlocal, gettz
```python
```python
<D/T/DT> = D/T/DT.fromisoformat(<str>) # Object from ISO string. Raises ValueError.
<D/T/DT> = D/T/DT.fromisoformat(<str>) # Object from ISO string. Raises ValueError.
<DT> = DT.strptime(<str>, '<format>') # Datetime from str, according to format.
<DT> = DT.strptime(<str>, '<format>') # Datetime from str, according to format.
<D/DTn> = D/DT.fromordinal(<int>) # D/DTn from days since the Gregorian NYE 1.
<DTn> = DT.fromtimestamp(<float>) # Local time DTn from seconds since the Epoch.
<D/DTn> = D/DT.fromordinal(<int>) # D/DT from days since the Gregorian NYE 1.
<DTn> = DT.fromtimestamp(<float>) # Local naive DT from seconds since the Epoch.
<DTa> = DT.fromtimestamp(<float>, <tz>) # Aware datetime from seconds since the Epoch.
<DTa> = DT.fromtimestamp(<float>, <tz>) # Aware datetime from seconds since the Epoch.
```
```
* **ISO strings come in following forms: `'YYYY-MM-DD'`, `'HH:MM:SS.mmmuuu[±HH:MM]'`, or both separated by an arbitrary character. All parts following the hours are optional.**
* **ISO strings come in following forms: `'YYYY-MM-DD'`, `'HH:MM:SS.mmmuuu[±HH:MM]'`, or both separated by an arbitrary character. All parts following the hours are optional.**
@ -639,7 +639,7 @@ from dateutil.tz import tzlocal, gettz
<str> = <D/T/DT>.isoformat(sep='T') # Also `timespec='auto/hours/minutes/seconds/…'`.
<str> = <D/T/DT>.isoformat(sep='T') # Also `timespec='auto/hours/minutes/seconds/…'`.
<str> = <D/T/DT>.strftime('<format>') # Custom string representation of the object.
<str> = <D/T/DT>.strftime('<format>') # Custom string representation of the object.
<int> = <D/DT>.toordinal() # Days since Gregorian NYE 1, ignoring time and tz.
<int> = <D/DT>.toordinal() # Days since Gregorian NYE 1, ignoring time and tz.
<float> = <DTn>.timestamp() # Seconds since the Epoch, from DTn in local tz.
<float> = <DTn>.timestamp() # Seconds since the Epoch, from local naive DT.
<float> = <DTa>.timestamp() # Seconds since the Epoch, from aware datetime.
<float> = <DTa>.timestamp() # Seconds since the Epoch, from aware datetime.
```
```
@ -752,7 +752,7 @@ Inline
### Lambda
### Lambda
```python
```python
<func> = lambda: <return_value> # A single statement function.
<func> = lambda: <return_value> # A single statement function.
<div><h3id="encode">Encode</h3><pre><codeclass="python language-python apache hljs"><D/T/DT> = D/T/DT.fromisoformat(<str>) <spanclass="hljs-comment"># Object from ISO string. Raises ValueError.</span>
<div><h3id="encode">Encode</h3><pre><codeclass="python language-python apache hljs"><D/T/DT> = D/T/DT.fromisoformat(<str>) <spanclass="hljs-comment"># Object from ISO string. Raises ValueError.</span>
<DT> = DT.strptime(<str>, <spanclass="hljs-string">'<format>'</span>) <spanclass="hljs-comment"># Datetime from str, according to format.</span>
<DT> = DT.strptime(<str>, <spanclass="hljs-string">'<format>'</span>) <spanclass="hljs-comment"># Datetime from str, according to format.</span>
<D/DTn> = D/DT.fromordinal(<int>) <spanclass="hljs-comment"># D/DTn from days since the Gregorian NYE 1.</span>
<DTn> = DT.fromtimestamp(<float>) <spanclass="hljs-comment"># Local time DTn from seconds since the Epoch.</span>
<D/DTn> = D/DT.fromordinal(<int>) <spanclass="hljs-comment"># D/DT from days since the Gregorian NYE 1.</span>
<DTn> = DT.fromtimestamp(<float>) <spanclass="hljs-comment"># Local naive DT from seconds since the Epoch.</span>
<DTa> = DT.fromtimestamp(<float>, <tz>) <spanclass="hljs-comment"># Aware datetime from seconds since the Epoch.</span>
<DTa> = DT.fromtimestamp(<float>, <tz>) <spanclass="hljs-comment"># Aware datetime from seconds since the Epoch.</span>
<div><h3id="decode">Decode</h3><pre><codeclass="python language-python hljs"><str> = <D/T/DT>.isoformat(sep=<spanclass="hljs-string">'T'</span>) <spanclass="hljs-comment"># Also `timespec='auto/hours/minutes/seconds/…'`.</span>
<div><h3id="decode">Decode</h3><pre><codeclass="python language-python hljs"><str> = <D/T/DT>.isoformat(sep=<spanclass="hljs-string">'T'</span>) <spanclass="hljs-comment"># Also `timespec='auto/hours/minutes/seconds/…'`.</span>
<str> = <D/T/DT>.strftime(<spanclass="hljs-string">'<format>'</span>) <spanclass="hljs-comment"># Custom string representation of the object.</span>
<str> = <D/T/DT>.strftime(<spanclass="hljs-string">'<format>'</span>) <spanclass="hljs-comment"># Custom string representation of the object.</span>
<int> = <D/DT>.toordinal() <spanclass="hljs-comment"># Days since Gregorian NYE 1, ignoring time and tz.</span>
<int> = <D/DT>.toordinal() <spanclass="hljs-comment"># Days since Gregorian NYE 1, ignoring time and tz.</span>
<float> = <DTn>.timestamp() <spanclass="hljs-comment"># Seconds since the Epoch, from DTn in local tz.</span>
<float> = <DTn>.timestamp() <spanclass="hljs-comment"># Seconds since the Epoch, from local naive DT.</span>
<float> = <DTa>.timestamp() <spanclass="hljs-comment"># Seconds since the Epoch, from aware datetime.</span>
<float> = <DTa>.timestamp() <spanclass="hljs-comment"># Seconds since the Epoch, from aware datetime.</span>
</code></pre></div>
</code></pre></div>
@ -642,7 +642,7 @@ func(*args, **kwargs)
<pre><codeclass="python language-python hljs">head, *body, tail = <coll.><spanclass="hljs-comment"># Head or tail can be omitted.</span>
<pre><codeclass="python language-python hljs">head, *body, tail = <coll.><spanclass="hljs-comment"># Head or tail can be omitted.</span>
</code></pre>
</code></pre>
<div><h2id="inline"><ahref="#inline"name="inline">#</a>Inline</h2><div><h3id="lambda">Lambda</h3><pre><codeclass="python language-python hljs"><func> = <spanclass="hljs-keyword">lambda</span>: <return_value><spanclass="hljs-comment"># A single statement function.</span>
<div><h2id="inline"><ahref="#inline"name="inline">#</a>Inline</h2><div><h3id="lambda">Lambda</h3><pre><codeclass="python language-python hljs"><func> = <spanclass="hljs-keyword">lambda</span>: <return_value><spanclass="hljs-comment"># A single statement function.</span>
<func> = <spanclass="hljs-keyword">lambda</span><arg_1>, <arg_2>: <return_value><spanclass="hljs-comment"># Also accepts default arguments.</span>
<func> = <spanclass="hljs-keyword">lambda</span><arg_1>, <arg_2>: <return_value><spanclass="hljs-comment"># Also allows default arguments.</span>
<pre><codeclass="python language-python hljs"><spanclass="hljs-meta">>>></span>[l+r <spanclass="hljs-keyword">for</span> l <spanclass="hljs-keyword">in</span><spanclass="hljs-string">'abc'</span><spanclass="hljs-keyword">for</span> r <spanclass="hljs-keyword">in</span><spanclass="hljs-string">'abc'</span>]
<pre><codeclass="python language-python hljs"><spanclass="hljs-meta">>>></span>[l+r <spanclass="hljs-keyword">for</span> l <spanclass="hljs-keyword">in</span><spanclass="hljs-string">'abc'</span><spanclass="hljs-keyword">for</span> r <spanclass="hljs-keyword">in</span><spanclass="hljs-string">'abc'</span>]<spanclass="hljs-comment"># Inner loop is on the right side.</span>
<div><h3id="anyall">Any, All</h3><pre><codeclass="python language-python hljs"><bool> = any(<collection>) <spanclass="hljs-comment"># Is `bool(<el>)` True for any element.</span>
<bool> = all(<collection>) <spanclass="hljs-comment"># Is True for all elements or empty.</span>
<div><h3id="anyall">Any, All</h3><pre><codeclass="python language-python hljs"><bool> = any(<collection>) <spanclass="hljs-comment"># Is `bool(<el>)` True for any el?</span>
<bool> = all(<collection>) <spanclass="hljs-comment"># Is True for all or is it empty?</span>
</code></pre></div>
</code></pre></div>
<div><h3id="conditionalexpression">Conditional Expression</h3><pre><codeclass="python language-python hljs"><obj> = <exp><spanclass="hljs-keyword">if</span><condition><spanclass="hljs-keyword">else</span><exp><spanclass="hljs-comment"># Only one expression gets evaluated.</span>
<div><h3id="conditionalexpression">Conditional Expression</h3><pre><codeclass="python language-python hljs"><obj> = <exp><spanclass="hljs-keyword">if</span><condition><spanclass="hljs-keyword">else</span><exp><spanclass="hljs-comment"># Only one expression is evaluated.</span>
</code></pre></div>
</code></pre></div>
<pre><codeclass="python language-python hljs"><spanclass="hljs-meta">>>></span>[a <spanclass="hljs-keyword">if</span> a <spanclass="hljs-keyword">else</span><spanclass="hljs-string">'zero'</span><spanclass="hljs-keyword">for</span> a <spanclass="hljs-keyword">in</span> (<spanclass="hljs-number">0</span>, <spanclass="hljs-number">1</span>, <spanclass="hljs-number">2</span>, <spanclass="hljs-number">3</span>)] <spanclass="hljs-comment"># `any([0, '', [], None]) == False`</span>
<pre><codeclass="python language-python hljs"><spanclass="hljs-meta">>>></span>[a <spanclass="hljs-keyword">if</span> a <spanclass="hljs-keyword">else</span><spanclass="hljs-string">'zero'</span><spanclass="hljs-keyword">for</span> a <spanclass="hljs-keyword">in</span> (<spanclass="hljs-number">0</span>, <spanclass="hljs-number">1</span>, <spanclass="hljs-number">2</span>, <spanclass="hljs-number">3</span>)] <spanclass="hljs-comment"># `any([0, '', [], None]) == False`</span>