Python Functions

_

  • __import__Imports a module. This is an advanced function that is not needed in everyday Python programming.

A

  • abs Returns the absolute value of a number.
  • aiterReturns an AsyncIterator for an AsyncIterable object.
  • allReturns True if all elements of the iterable are true (or if the iterable is empty).
  • anextReturns the next item from an async iterator.
  • anyReturns True if any element of the iterable is true. If the iterable is empty, return False.
  • asciiReturns a string containing a printable representation of an object, escaping non-ASCII characters.
  • addAdds an element to the set.
  • appendAdd an item to the end of the list.

B

  • binReturns the binary representation of an integer.
  • boolReturns a Boolean value, i.e. one of True or False.
  • breakpointDrops you into the debugger at the call site.
  • bytearrayReturns a new array of bytes. The bytearray type is a mutable sequence of integers in the range 0 <= x < 256.
  • bytesReturns a new 'bytes' object, which is an immutable sequence of integers in the range 0 <= x < 256.

C

  • callableReturns True if the object argument appears callable, False if not.
  • chrReturns a string of one character whose Unicode code point is the integer i.
  • classmethodTransforms a method into a class method.
  • compileCompiles the source into a code or AST object.
  • complexCreates a complex number with the value real + imag*1j or convert a string or number to a complex number.
  • clear (dict)Removes all items from the dictionary.
  • clear (list)Removes all items from the list.
  • clear (set)Removes all elements from this set.
  • copy (dict)Returns a shallow copy of the dictionary.
  • copy (list)Returns a shallow copy of the list.
  • copy (set)Returns a shallow copy of the set.
  • count (tuple)Returns the number of times a specified value occurs in a tuple.
  • count (list)Returns the number of times a specified value occurs in a list.
  • count (str)Returns the number of non-overlapping occurrences of substring sub in string.
  • closeClose the file. A closed file cannot be read or written any more.
  • capitalizeReturn a capitalized version of the string.
  • casefoldReturn a casefolded copy of the string.
  • centerReturn a centered string of length width.

D

  • delattrDeletes the named attribute from the given object.
  • dictCreates a new dictionary.
  • divmodReturns a tuple of the quotient and remainder when dividing a by b.
  • differenceReturns the difference of two or more sets as a new set.
  • difference_updateRemoves all elements of another set from this set.
  • discardRemoves an element from a set if it is a member.
  • dirReturns a list of valid attributes for the given object.

E

  • enumerateReturns an enumerate object.
  • evalEvaluates a Python expression as a string and return the result.
  • execExecutes Python code dynamically.
  • extendExtend the list by appending all the items from the iterable.
  • encodeReturn an encoded version of the string as a bytes object.
  • endswithReturn True if the string ends with the specified suffix, False otherwise.
  • expandtabsReturn a copy of the string where all tab characters are replaced by one or more spaces.

F

  • filterConstructs an iterator from elements of iterable for which function returns True.
  • floatConverts a string or number to a floating point number.
  • format(Any)Returns value.__format__(format_spec).
  • frozensetReturns an immutable set object initialized from iterable.
  • fromkeysCreates a new dictionary with keys from iterable and values set to value.
  • filenoReturn the underlying file descriptor (an integer).
  • flushFlush the write buffers of the stream if applicable.
  • findReturn the lowest index in the string where substring sub is found.
  • format(string)Perform a string formatting operation.

G

  • getattrGets a named attribute from an object; getattr(x, 'y') is equivalent to x.y.
  • globalsReturns the dictionary containing the current scope's global variables.
  • getReturns the value for key if key is in the dictionary, else default.

H

  • hasattrReturns whether the object has an attribute with the given name.
  • hashReturns the hash value of the object (if it has one).
  • helpInvokes the built-in help system.
  • hexReturns the hexadecimal representation of an integer.

I

  • idReturns the identity of an object.
  • inputReads a string from standard input.
  • intConverts a number or string to an integer, or return 0 if no arguments are given.
  • isinstanceReturns whether an object is an instance of a class or of a subclass thereof.
  • issubclassReturns whether 'class' is a derived from another class or is the same class.
  • iterReturns an iterator object.
  • itemsReturns a new view of the dictionary's items ((key, value) pairs).
  • index (tuple)Returns the index of the first occurrence of the specified value.
  • index (list)Returns the index of the first occurrence of the specified value.
  • index (str)Returns the lowest index where the substring is found.
  • intersectionReturn the intersection of two sets as a new set.
  • intersection updateUpdate the set with the intersection of itself and another.
  • isdisjointReturn True if two sets have a null intersection.
  • issubsetReport whether another set contains this set.
  • issupersetReport whether this set contains another set.
  • isattyReturn True if the file is connected to a tty(-like) device.
  • insertInsert an item at a given position.
  • isalnumReturn True if all characters in the string are alphanumeric and there is at least one character, False otherwise.
  • isalphaReturn True if all characters in the string are alphabetic and there is at least one character, False otherwise.
  • isasciiReturn True if all characters in the string are ASCII, False otherwise.
  • isdecimalReturn True if all characters in the string are decimal characters and there is at least one character, False otherwise.
  • isdigitReturn True if all characters in the string are digits and there is at least one character, False otherwise.
  • isidentifierReturn True if the string is a valid Python identifier, False otherwise.
  • islowerReturn True if all cased characters in the string are lowercase and there is at least one cased character, False otherwise.
  • isnumericReturn True if all characters in the string are numeric characters, and there is at least one character, False otherwise.
  • isprintableReturn True if all characters in the string are printable or the string is empty, False otherwise.
  • isspaceReturn True if there are only whitespace characters in the string and there is at least one character, False otherwise.
  • istitleReturn True if the string is a titlecased string and there is at least one character, False otherwise.
  • isupperReturn True if all cased characters in the string are uppercase and there is at least one cased character, False otherwise.

J

  • joinReturn a string which is the concatenation of the strings in iterable.

K

  • keysReturns a new view of the dictionary's keys.

L

  • lenReturns the length (the number of items) of an object.
  • listBuilt-in mutable sequence.
  • localsReturns a dictionary containing the current scope's local variables.
  • ljustReturn left-justified string of length width.
  • lowerReturn a copy of the string converted to lowercase.
  • lstripReturn a copy of the string with leading characters removed.

M

  • mapApplies function to every item of iterable and return an iterator of the results.
  • maxReturns the largest item in an iterable or the largest of two or more arguments.
  • memoryviewCreates a memory view object from a bytes-like object.
  • minReturns the smallest item in an iterable or the smallest of two or more arguments.
  • maketransReturn a translation table usable for str.translate().

N

  • nextRetrieves the next item from the iterator.

O

  • objectThe base class of the class hierarchy.
  • octReturns the octal representation of an integer.
  • openOpens file and return a corresponding file object.
  • ordReturns the Unicode code point for a one-character string.

P

  • powReturns base to the power exp; if mod is present, return base to the power exp, modulo mod.
  • printPrints objects to the text stream file, separated by sep and followed by end.
  • propertyProperty attribute.
  • pop (dict)Removes specified key and return the corresponding value.
  • pop (list)Removes and return item at index (default last).
  • pop (set)Removes and return an arbitrary set element. Raises KeyError if the set is empty.
  • popitemRemoves and return a (key, value) pair as a 2-tuple.
  • partitionPartition the string into three parts using the given separator.

R

  • rangeReturns an object that produces a sequence of integers from start to stop by step.
  • reprReturns a string containing a printable representation of an object.
  • reversedReturns a reverse iterator over the values of the given sequence.
  • roundRounds a number to a given precision in decimal digits.
  • remove (set)Remove an element from a set; it must be a member.
  • remove (list)Remove the first occurrence of a value in the list.
  • readRead at most size characters from stream. If size is negative or None, read until EOF.
  • readableReturn True if the file stream can be read from.
  • readlineRead until newline or EOF and return a single line of text.
  • readlinesRead and return a list of lines from the stream.
  • reverseReverse the elements of the list in place.
  • replaceReturns a copy with all occurrences of substring old replaced by new.
  • rfindReturns the highest index in the string where substring sub is found.
  • rindexReturns the highest index in the string where substring sub is found.
  • rjustReturns right-justified string of length width.
  • rpartitionPartition the string into three parts using the given separator.
  • rsplitReturns a list of the words in the string, using sep as the delimiter string.
  • rstripReturns a copy of the string with trailing characters removed.

S

  • setReturns a new set object, optionally with elements taken from iterable.
  • setattrSets a named attribute on an object with the given value.
  • sliceCreates a slice object. Used for extended slicing (e.g. a[start:stop:step]).
  • sortedReturns a new sorted list from the items in iterable.
  • staticmethodTransforms a method into a static method.
  • strReturns a string version of object.
  • sumReturns the sum of a 'start' value (default: 0) plus an iterable of numbers.
  • superReturns a proxy object that delegates method calls to a parent or sibling class of type.
  • setdefaultInserts key with a value of default if key is not in the dictionary.
  • symmetric_differenceReturn the symmetric difference of two sets as a new set.
  • symmetric_difference_updateUpdate a set with the symmetric difference of itself and another.
  • seekChange the stream position to the given byte offset.
  • seekableReturn True if the stream supports random access.
  • sortSort the list in ascending order and return None.
  • splitReturns a list of the words in the string, using sep as the delimiter string.
  • splitlinesReturns a list of the lines in the string, breaking at line boundaries.
  • startswithReturns True if string starts with the specified prefix, False otherwise.
  • stripReturns a copy of the string with leading and trailing characters removed.
  • swapcaseReturns a copy of the string with uppercase characters converted to lowercase and vice versa.

T

  • tupleReturns a tuple whose items are the same and in the same order as iterable's items.
  • typeReturns the type of an object, or create a new type object.
  • tellReturn the current stream position.
  • truncateResize the stream to the given size in bytes (or the current position if size is not specified).
  • titleReturns a titlecased version of the string where words start with an uppercase character and the remaining characters are lowercase.
  • translateReturns a copy of the string in which each character has been mapped through the given translation table.

U

  • update(dictionary)Updates the dictionary with the key/value pairs from other, overwriting existing keys.
  • unionReturn the union of sets as a new set.
  • update(set)Update a set with the union of itself and others.
  • upperReturns a copy of the string converted to uppercase.

V

  • varsReturns the __dict__ attribute for a module, class, instance, or any other object with a __dict__ attribute.
  • valuesReturns a new view of the dictionary's values.

W

  • writableReturn True if the stream supports writing.
  • writeWrite string s to the stream and return the number of characters written.
  • writelinesWrite a list of lines to the stream. Line separators are not added.

Z

  • zipReturns an iterator of tuples where the i-th tuple contains the i-th element from each of the argument sequences or iterables.
  • zfillReturns a copy of the string left filled with ASCII '0' digits to make a string of length width.