pyguides

Reference

Built-in Functions

Python built-in functions available without imports.

  1. abs()

    The built-in abs function returns the absolute value of a number, removing its sign. Works with integers, floats, and objects implementing __abs__

  2. aiter()

    Return an async iterator for an asynchronous iterable. Used with async for loops to iterate over async iterables.

  3. aiter()

    Return an asynchronous iterator for an asynchronous iterable. Added in Python 3.10.

  4. all()

    The built-in all function returns True if all elements of an iterable are truthy (or if the iterable is empty)

  5. anext()

    The built-in anext function retrieves the next item from an async iterator, with optional default value for exhausted iterators

  6. anext()

    Await the next item from an async iterator. Returns a default if provided instead of raising StopAsyncIteration.

  7. any()

    The built-in any function returns True if any element of an iterable is truthy

  8. ascii()

    The built-in ascii function returns a string containing a printable representation of an object, escaping non-ASCII characters

  9. bin()

    The built-in bin function converts an integer to a binary string prefixed with '0b'

  10. bool()

    The built-in bool function converts a value to a boolean (True or False)

  11. breakpoint()

    Drop into the Python debugger at the call site. Configurable via PYTHONBREAKPOINT.

  12. breakpoint()

    The built-in breakpoint function invokes the debugger by calling pdb.run() or the configured debugger

  13. bytearray()

    The built-in bytearray function returns a mutable sequence of bytes that can be modified in place

  14. bytes()

    The built-in bytes function returns an immutable bytes object, used for working with binary data

  15. callable()

    The built-in callable function checks if an object appears callable, returning True or False

  16. chr()

    The built-in chr function returns a string representing a character whose Unicode code point is the given integer

  17. classmethod()

    The built-in classmethod function transforms a method into a class method, receiving the class as the first argument instead of an instance

  18. compile()

    The built-in compile function compiles a source string or AST object into a code object that can be executed by exec() or eval()

  19. complex()

    The built-in complex function creates a complex number or converts a number or string to a complex number

  20. delattr()

    Deletes a named attribute from an object. Removes the attribute specified by name from the given object.

  21. dict()

    The built-in dict function creates a new dictionary object, either empty or from key-value pairs

  22. dir()

    The built-in dir function returns a list of names in the current local scope or the attributes of an object.

  23. divmod()

    The built-in divmod function takes two numbers and returns a tuple containing their quotient and remainder.

  24. enumerate()

    The built-in enumerate function adds a counter to an iterable and returns it as an enumerate object that yields index-element pairs.

  25. eval()

    The built-in eval function evaluates a Python expression as a string and returns the result. Use with caution on untrusted input due to security risks

  26. exec()

    The built-in exec function executes dynamically created Python code from a string or compiled code object. Use with caution on untrusted input.

  27. filter()

    Return an iterator yielding items from an iterable for which a function returns true.

  28. float()

    The built-in float() function converts a number or string to a floating-point number.

  29. format()

    Convert a value to a formatted string using Python's format specification mini-language. The builtin behind f-strings and str.format().

  30. format()

    The built-in format function converts values to formatted strings using a format spec mini-language. Essential for precise numeric and string presentation.

  31. frozenset()

    The built-in frozenset function creates an immutable set object that cannot be modified after creation

  32. getattr()

    The built-in getattr function returns the value of an object attribute by name, with optional default for missing attributes

  33. globals()

    The built-in globals function returns a dictionary representing the current global namespace, enabling dynamic access and modification of global variables

  34. hasattr()

    The built-in hasattr function checks if an object has a named attribute, returning True if the attribute exists and False otherwise

  35. hash()

    Return the hash value of an object. Hash values are integers used to quickly compare dictionary keys during a dictionary lookup.

  36. help()

    Invoke the built-in help system to display documentation for objects, modules, functions, and other Python constructs.

  37. hex()

    The built-in hex function converts an integer to a lowercase hexadecimal string with a '0x' prefix.

  38. id()

    The built-in id function returns the unique identity integer of an object, which corresponds to its memory address in CPython

  39. input()

    The built-in input function reads a line from standard input, converts it to a string, and returns it

  40. int()

    The built-in int function converts a number or string to an integer. Supports different bases for string conversion and handles float truncation

  41. isinstance()

    The built-in isinstance function checks if an object is an instance of a class or tuple of classes, supporting type checking for clean, pythonic code

  42. issubclass()

    The built-in issubclass() function checks if a class is a subclass of another class or tuple of classes

  43. iter()

    The built-in iter function returns an iterator object from an iterable or a callable with a sentinel value

  44. len()

    The built-in len function returns the number of items in a container or the length of a string

  45. list()

    The built-in list constructor creates a new list from an iterable or returns an empty list

  46. locals()

    The built-in locals function returns a dictionary of the current local namespace, providing access to local variables within the current scope

  47. map()

    The built-in map function applies a function to every item in an iterable and returns an iterator with the results

  48. max()

    The built-in max function returns the largest item from an iterable or the largest of two or more arguments

  49. memoryview()

    Create a memory view object that exposes the underlying buffer of a bytes or bytearray object without copying.

  50. min()

    The built-in min function returns the smallest item from an iterable or the smallest of two or more arguments

  51. next()

    The built-in next function retrieves the next item from an iterator, returning a default value if the iterator is exhausted.

  52. object()

    The base class for all objects in Python, providing default implementations for common methods.

  53. oct()

    The built-in oct function converts an integer to an octal string with a '0o' prefix.

  54. open()

    The built-in open function opens a file and returns a file object for reading, writing, or modifying file contents

  55. ord()

    The built-in ord function returns an integer representing the Unicode code point of a character

  56. pow()

    The built-in pow function computes base raised to the power of exp, with optional modulus for efficient modular exponentiation.

  57. print()

    The built-in print function writes objects to a text stream, separated by sep and followed by end

  58. property()

    The built-in property function creates a property attribute for managed access to class attributes

  59. range()

    The built-in range function generates an immutable sequence of integers, commonly used for looping a specific number of times

  60. repr()

    The built-in repr function returns a string containing a printable representation of an object, often useful for debugging and logging.

  61. reversed()

    The built-in reversed function returns a reverse iterator over a sequence or other object supporting iteration.

  62. round()

    The built-in round function rounds a number to a given number of decimal places. Uses banker's rounding (round half to even).

  63. set()

    The built-in set function creates a new set object from an iterable, or an empty set if no argument is provided

  64. setattr()

    The built-in setattr function sets a named attribute on an object at runtime

  65. slice()

    The built-in slice function creates a slice object for extracting portions of sequences

  66. sorted()

    The built-in sorted function returns a new sorted list from the items in an iterable, with optional key and reverse parameters for customization.

  67. staticmethod()

    The staticmethod decorator transforms a function into a static method that can be called on a class without instantiating it

  68. str()

    The built-in str function converts an object to a string representation

  69. sum()

    The built-in sum function returns the total of all items in an iterable plus an optional starting value.

  70. super()

    The built-in super function returns a proxy object that delegates method calls to a parent or sibling class

  71. tuple()

    The built-in tuple function converts an iterable into a tuple, creating an immutable, ordered sequence of elements

  72. type()

    The built-in type function returns the type of an object or creates a new type dynamically

  73. vars()

    The built-in vars function returns the __dict__ attribute of an object, or the current local symbol table as a dictionary

  74. zip()

    The built-in zip function iterates over multiple iterables in parallel, returning tuples of corresponding elements