diff --git a/README.md b/README.md index 892fba0..8dc9055 100644 --- a/README.md +++ b/README.md @@ -232,17 +232,9 @@ Type ```python = type() # Or: = .__class__ - = isinstance(, ) # Also true if 'type' is a superclass of el's type. + = isinstance(, ) # Also checks subclasses and ABCs. ``` -```python - = .__bases__ # A tuple of type's parents. - = .mro() # Returns a list of all type's superclasses. - = issubclass(, ) # Checks if 'sub_type' is a subclass of 'type'. -``` - -* **Every class is a subclass and a superclass of itself.** - ```python >>> type('a'), 'a'.__class__, str (, , ) @@ -254,6 +246,7 @@ from types import FunctionType, MethodType, LambdaType, GeneratorType ``` ### ABC-s +**Abstract base classes introduce virtual subclasses, that don’t inherit from a class but are still recognized by isinstance().** ```python from numbers import Integral, Rational, Real, Complex, Number = isinstance(, Number) diff --git a/index.html b/index.html index 01328de..1de9356 100644 --- a/index.html +++ b/index.html @@ -308,15 +308,8 @@ Point(x=1, y=2
  • Type and class are synonymous.
  • <type>  = type(<el>)                      # Or: <type> = <el>.__class__
    -<bool>  = isinstance(<el>, <type>)        # Also true if 'type' is a superclass of el's type.
    +<bool>  = isinstance(<el>, <type>)        # Also checks subclasses and ABCs.
     
    -
    <tuple> = <type>.__bases__                # A tuple of type's parents.
    -<list>  = <type>.mro()                    # Returns a list of all type's superclasses.
    -<bool>  = issubclass(<sub_type>, <type>)  # Checks if 'sub_type' is a subclass of 'type'.
    -
    -
      -
    • Every class is a subclass and a superclass of itself.
    • -
    >>> type('a'), 'a'.__class__, str
     (<class 'str'>, <class 'str'>, <class 'str'>)
     
    @@ -324,6 +317,7 @@ Point(x=1, y=2
    from types import FunctionType, MethodType, LambdaType, GeneratorType
     

    ABC-s

    +

    Abstract base classes introduce virtual subclasses, that don’t inherit from a class but are still recognized by isinstance().

    from numbers import Integral, Rational, Real, Complex, Number
     <bool> = isinstance(<el>, Number)