What is the use of the issubclass function in Python?
Learn how issubclass() checks class inheritance, how it differs from isinstance(), and how to use it for plugin registries and validation.
Spread Your Knowledge. Questions with answers, tutorials and articles, newest first.
Learn how issubclass() checks class inheritance, how it differs from isinstance(), and how to use it for plugin registries and validation.
Learn how isinstance() checks an object against a class, a tuple or a union, how it differs from type(), and when to use abstract base classes.
id() returns a unique number for an object during its lifetime. See how it relates to is, aliasing, small-integer caching and mutable objects.
Python's type() returns the class of any object and can build new classes at runtime. See how it differs from isinstance() and when to use each one.
help() prints documentation for any Python object from the interpreter. See how to read docstrings, look up keywords and write docstrings that help shows well.
dir() returns a sorted list of names for an object, module or the current scope. See how to filter it, customize it and when to use vars() instead.
str.format() replaces placeholders with values and controls width, alignment, precision and number style. Compare it with f-strings.
round() rounds numbers to decimal places or to the nearest integer. Learn banker's rounding, float surprises like round(2.675, 2), and the Decimal alternative.
Python pow() computes powers and fast modular exponentiation. See syntax, return types, how it differs from ** and math.pow, and modular inverses.
divmod(a, b) returns (a // b, a % b) in one call. See how it handles negatives and floats, plus time, pagination and money examples.
Python's abs() returns a number's absolute value or a complex number's magnitude. See examples, custom __abs__ support, float tolerance checks, and pitfalls.
Python min() and max() return the smallest and largest items of an iterable. See the key and default parameters, tie behaviour and common errors.
Python's sum() adds up the items of any iterable and returns the total. See the syntax, the start parameter, generator expressions and the pitfalls with floats and strings.
reversed() returns a lazy iterator that walks a sequence from last to first without changing it. See how it works with lists, strings, ranges, dicts and custom classes.
Learn how Python's sorted function works, with key and reverse examples, multi-field sorting, stability and the difference from list.sort().
any() checks whether at least one element is truthy and all() checks whether every element is. See examples, edge cases and pitfalls.
functools.reduce() combines the items of an iterable into a single value. See how it works, the initial value, practical examples, and when sum() or accumulate() is better.
filter() lazily keeps the items of an iterable for which a predicate is true. See examples and how it compares with list comprehensions.
Python map() applies a function to every item of an iterable and returns a lazy iterator. See examples, multiple iterables and when to use a comprehension.
List comprehensions are eager and reusable, generator expressions are lazy and memory-efficient. Learn when to use each in Python.