Draft for Information Only
Content
Python Built-in Functions Built-in Functions Source and Reference
Python Built-in Functions
The Python interpreter has some built-in function blocks that are always available for calling in Python programs.
Built-in Functions
abs()to return the absolute value of a number
all()to return True if all elements of the iterable are true (or if the iterable is empty).
any()to return True if any element of the iterable is true. Return False, if the iterable is empty
ascii()to return a string containing a printable representation of an object, but escape the non-ASCII characters in the string returned by repr() using \x, \u, or \U
bin()to convert an integer number to a binary string prefixed with "0b"
class bool()to return a Boolean value, True or False
breakpoint()to drop into the debugger
bytearray()to return a new array of bytes
bytes()to return a new bytes object
callable()to return a True if the object argument appears callable, False if not
chr()to return the string of a Unicode code point
classmethod()to transform a method into a class method
compile()to compile the source into a code or AST object
complex()to return a complex number with the value real+imag*1j or convert a string or number to a complex number
delattr()to delete the named attribute, provided the object allows it
dict()to create a new dictionary
dir()to return the list of names in the current local scope, or a list of valid attributes for specified object.
divmod()to return a pair of numbers consisting of their quotient and remainder when using integer division by taking two non complex numbers as arguments.
enumerate()to return an enumerate object
eval()to return the result of the evaluated expression
exec()to execute the given Python code
filter()to construct an iterator from those elements of iterable for which function returns true
float()to return a floating point number constructed from a number or string
format()to convert a value to a formatted representation
frozenset()to return a new frozenset object
getattr()to return the value of the named attribute of object
globals()to return a dictionary representing the current global symbol table
hasattr()to return True if the object has the specified attribute
hash()to return the hash value of the object
help()to invoke the built-in help system
hex()to convert an integer number to a lowercase hexadecimal string prefixed with "0x"
id()to return the identity of an object
input()to read a line from input
int()to return an integer object
isinstance()to return True if the object argument is an instance of the classinfo argument or of a subclass thereof
issubclass()to return True if class is a subclass
iter()to return an iterator object
len()to return the length or the item number of an object
list()to return a list object
locals()to update and return a dictionary representing the current local symbol table
map()to return an iterator that applies functio to every item of iterable, yielding the results
max()to return the largest item in an iterable or arguments
memoryview()to return a memory view object created from the given argument
min()to return the smallest item in an iterable or arguments
next()to retrieve the next item from the iterator by calling its __next__() method
object()to return a new featureless object.
oct()to convert an integer number to an octal string prefixed with "0o"
open()to open file and return a corresponding file object
ord()to return an integer representing the Unicode code point
pow()to return base to the power exp
print()to print objects to the text stream file
property()to return a property attribute
range()to return a range
repr()to return a string containing a printable representation of an object
reversed()to return a reverse iterator
round()to return number rounded to ndigits precision after the decimal point
set()to return a new set object
setattr()to assign the value to the attribute, provided the object allows it
slice()to return a slice object representing the set of indices specified by range
sorted()to return a new sorted list from the items in iterable
staticmethod()to transform a method into a static method
str()to return a str version of object
sum()to return the total of iterable from left to right
super()to return a proxy object that delegates method calls to a parent or sibling class of type.
tuple()to return a tuple
type()to return the type of an object
vars()to return the __dict__ attribute for a module, class, instance, or any othe object with a __dict__ attribute
zip()to return an iterator of tuples, where the i-th tuple contains the i-th element from each of the argument sequence or iterables.
__import__()to import the module name, potentially using the given globals and locals to determine how to interpret the name in a package context
Source and Reference
©sideway
ID: 200601502 Last Updated: 6/15/2020 Revision: 0
|
|