From edf82f817904356839c386ef83b1abf89a45f1ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Fri, 10 Jan 2020 16:00:36 +0100 Subject: [PATCH] Datetime, Duck types --- README.md | 5 ++--- index.html | 4 ++-- web/index_for_pdf.html | 2 +- web/index_for_pdf_print.html | 2 +- web/script_2.js | 4 ++-- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 36dd8aa..948342a 100644 --- a/README.md +++ b/README.md @@ -584,7 +584,7 @@ from itertools import product, combinations, combinations_with_replacement, perm Datetime -------- * **Module 'datetime' provides 'date' ``, 'time' ``, 'datetime' `
` and 'timedelta' `` classes. All are immutable and hashable.** -* **Time and datetime can be 'aware' ``, meaning they have defined timezone, or 'naive' ``, meaning they don't.** +* **Time and datetime objects can be 'aware' ``, meaning they have defined timezone, or 'naive' ``, 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(, '', value) delattr(, '') ``` - ### Parameters ```python from inspect import signature diff --git a/index.html b/index.html index 71894d3..efbfcf4 100644 --- a/index.html +++ b/index.html @@ -639,7 +639,7 @@ shuffle(<list>)

#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.
from datetime import date, time, datetime, timedelta
 from dateutil.tz import UTC, tzlocal, gettz, resolve_imaginary
@@ -1194,7 +1194,7 @@ Hello World!
 

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.
from collections import abc
 
 class MyAbcSequence(abc.Sequence):
diff --git a/web/index_for_pdf.html b/web/index_for_pdf.html
index 894e4cd..dcc0103 100644
--- a/web/index_for_pdf.html
+++ b/web/index_for_pdf.html
@@ -37,7 +37,7 @@
 csv module, 26, 34
curses module, 34

D

-

dataclasses module, 15
+

dataclasses module, 12, 15
datetime module, 8-9
decorator, 13
deques, 29
diff --git a/web/index_for_pdf_print.html b/web/index_for_pdf_print.html index 03a82c1..c430246 100644 --- a/web/index_for_pdf_print.html +++ b/web/index_for_pdf_print.html @@ -41,7 +41,7 @@ csv module, 26, 34
curses module, 34

D

-

dataclasses module, 15
+

dataclasses module, 12, 15
datetime module, 8-9
decorator, 13
deques, 29
diff --git a/web/script_2.js b/web/script_2.js index 4ae9768..0c00e8c 100644 --- a/web/script_2.js +++ b/web/script_2.js @@ -173,9 +173,9 @@ const DIAGRAM_8_B = " │ └── ZeroDivisionError # Raised when dividing by zero.\n" + " ├── AttributeError # Raised when an attribute is missing.\n" + " ├── EOFError # Raised by input() when it hits end-of-file condition.\n" + - " ├── LookupError # Raised when a look-up on a sequence or dict fails.\n" + + " ├── LookupError # Raised when a look-up on a collection fails.\n" + " │ ├── IndexError # Raised when a sequence index is out of range.\n" + - " │ └── KeyError # Raised when a dictionary key is not found.\n" + + " │ └── KeyError # Raised when a dictionary key or set element is not found.\n" + " ├── NameError # Raised when a variable name is not found.\n" + " ├── OSError # Failures such as “file not found” or “disk full”.\n" + " │ └── FileNotFoundError # When a file or directory is requested but doesn't exist.\n" +