**Each abstract base class specifies a set of virtual subclasses. This classes get recognized by isinstance() and issubclass() as subclasses of the ABC, although they are really not.**
**Each abstract base class specifies a set of virtual subclasses. This classes are then recognized by isinstance() and issubclass() as subclasses of the ABC, although they are really not.**
```python
>>> from collections.abc import Sequence, Collection, Iterable
@ -500,7 +500,7 @@ Numbers
### Math
```python
from math import e, pi, inf, nan
from math import e, pi, inf, nan, isinf, isnan
from math import cos, acos, sin, asin, tan, atan, degrees, radians
from math import log, log10, log2
```
@ -1255,7 +1255,7 @@ class MySequence:
return reversed(self.a)
```
### Collections.abc.Sequence
### 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, abc.Sequence)'` would return False even if MySequence had all the methods defined.**
@ -1415,7 +1415,7 @@ BaseException
+-- NameError # Raised when a variable name is not found.
+-- OSError # Failures such as “file not found” or “disk full”.
| +-- FileNotFoundError # When a file or directory is requested but doesn't exist.
+-- RuntimeError # Raised by errors that don't fall in other categories.
+-- RuntimeError # Raised by errors that don't fall into other categories.
| +-- RecursionError # Raised when the maximum recursion depth is exceeded.
+-- StopIteration # Raised by next() when run on an empty iterator.
+-- TypeError # Raised when an argument is of wrong type.
@ -1458,8 +1458,8 @@ Exit
```python
import sys
sys.exit() # Exits with exit code 0 (success).
sys.exit(<int>) # Exits with passed exit code.
sys.exit(<obj>) # Prints the object and exits with 1 (failure).
sys.exit(<el>) # Prints object to stderr and exits with 1.
sys.exit(<int>) # Exits with the passed exit code.
<div><h4id="sometypesdonothavebuiltinnamessotheymustbeimported">Some types do not have built-in names, so they must be imported:</h4><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">from</span> types <spanclass="hljs-keyword">import</span> FunctionType, MethodType, LambdaType, GeneratorType
</code></pre></div>
<div><h3id="abstractbaseclasses">Abstract Base Classes</h3><p><strong>Each abstract base class specifies a set of virtual subclasses. This classes get recognized by isinstance() and issubclass() as subclasses of the ABC, although they are really not.</strong></p><pre><codeclass="python language-python hljs"><spanclass="hljs-meta">>>></span><spanclass="hljs-keyword">from</span> collections.abc <spanclass="hljs-keyword">import</span> Sequence, Collection, Iterable
<div><h3id="abstractbaseclasses">Abstract Base Classes</h3><p><strong>Each abstract base class specifies a set of virtual subclasses. This classes are then recognized by isinstance() and issubclass() as subclasses of the ABC, although they are really not.</strong></p><pre><codeclass="python language-python hljs"><spanclass="hljs-meta">>>></span><spanclass="hljs-keyword">from</span> collections.abc <spanclass="hljs-keyword">import</span> Sequence, Collection, Iterable
<div><h3id="math">Math</h3><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">from</span> math <spanclass="hljs-keyword">import</span> e, pi, inf, nan
<div><h3id="math">Math</h3><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">from</span> math <spanclass="hljs-keyword">import</span> e, pi, inf, nan, isinf, isnan
<spanclass="hljs-keyword">from</span> math <spanclass="hljs-keyword">import</span> cos, acos, sin, asin, tan, atan, degrees, radians
<spanclass="hljs-keyword">from</span> math <spanclass="hljs-keyword">import</span> log, log10, log2
<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 <codeclass="python hljs"><spanclass="hljs-string">'abc.Iterable'</span></code> and <codeclass="python hljs"><spanclass="hljs-string">'abc.Collection'</span></code>, it is not a duck type. That is why <codeclass="python hljs"><spanclass="hljs-string">'issubclass(MySequence, abc.Sequence)'</span></code> would return False even if MySequence had all the methods defined.</strong></li>
<div><h2id="exit"><ahref="#exit"name="exit">#</a>Exit</h2><p><strong>Exits the interpreter by raising SystemExit exception.</strong></p><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">import</span> sys
sys.exit() <spanclass="hljs-comment"># Exits with exit code 0 (success).</span>
sys.exit(<int>)<spanclass="hljs-comment"># Exits with passed exit code.</span>
sys.exit(<obj>) <spanclass="hljs-comment"># Prints the object and exits with 1 (failure).</span>
sys.exit(<el>) <spanclass="hljs-comment"># Prints object to stderr and exits with 1.</span>
sys.exit(<int>) <spanclass="hljs-comment"># Exits with the passed exit code.</span>