7e559f6dad
Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com>
12 KiB
12 KiB
Built-in Functions
{:.no_toc}
* TOC {:toc}The goal
Do I need to know what all these functions are doing? No, but you are shouldn't use these function names for your own functions!
However... I marked the one in bold font that you should know.
Questions to David Rotermund
abs() | Return the absolute value of a number. |
aiter() | Return an asynchronous iterator for an asynchronous iterable. |
all() | Return True if all elements of the iterable are true (or if the iterable is empty). |
anext() | When awaited, return the next item from the given asynchronous iterator, or default if given and the iterator is exhausted. |
any() | Return True if any element of the iterable is true. If the iterable is empty, return False. |
ascii() | As repr(), return a string containing a printable representation of an object, but escape the non-ASCII characters in the string |
bin() | Convert an integer number to a binary string prefixed with “0b”. |
bool() | Return a Boolean value, i.e. one of True or False. |
breakpoint() | This function drops you into the debugger at the call site. |
bytearray() | Return a new array of bytes. |
bytes() | Return a new “bytes” object which is an immutable sequence of integers in the range 0 <= x < 256. |
callable() | Return True if the object argument appears callable, False if not. If this returns True, it is still possible that a call fails, but if it is False, calling object will never succeed. |
chr() | Return the string representing a character whose Unicode code point is the integer i. |
classmethod() | Transform a method into a class method. |
compile() | Compile the source into a code or AST object. Code objects can be executed by exec() or eval(). source can either be a normal string, a byte string, or an AST object. |
complex() | Return a complex number with the value real + imag*1j or convert a string or number to a complex number. |
delattr() | This is a relative of setattr(). |
dict() | Create a new dictionary. |
dir() | Without arguments, return the list of names in the current local scope. With an argument, attempt to return a list of valid attributes for that object. |
divmod() | Take two (non-complex) numbers as arguments and return a pair of numbers consisting of their quotient and remainder when using integer division. |
enumerate() | Return an enumerate object. iterable must be a sequence, an iterator, or some other object which supports iteration. |
eval() | The expression argument is parsed and evaluated as a Python expression (technically speaking, a condition list) using the globals and locals dictionaries as global and local namespace. |
exec() | This function supports dynamic execution of Python code. |
filter() | Construct an iterator from those elements of iterable for which function is true. |
float() | Return a floating point number constructed from a number or string x. |
format() | Convert a value to a “formatted” representation, as controlled by format_spec. |
frozenset() | Return a new frozenset object, optionally with elements taken from iterable. |
getattr() | Return the value of the named attribute of object. name must be a string. |
globals() | Return the dictionary implementing the current module namespace. |
hasattr() | The arguments are an object and a string. The result is True if the string is the name of one of the object’s attributes, False if not. |
hash() | Return the hash value of the object (if it has one). Hash values are integers. They are used to quickly compare dictionary keys during a dictionary lookup. |
help() | Invoke the built-in help system. (This function is intended for interactive use.) |
hex() | Convert an integer number to a lowercase hexadecimal string prefixed with “0x”. |
id() | Return the “identity” of an object. This is an integer which is guaranteed to be unique and constant for this object during its lifetime. Two objects with non-overlapping lifetimes may have the same id() value. |
input() | If the prompt argument is present, it is written to standard output without a trailing newline. The function then reads a line from input, converts it to a string (stripping a trailing newline), and returns that. |
int() | Return an integer object constructed from a number or string x, or return 0 if no arguments are given. |
isinstance() | Return True if the object argument is an instance of the classinfo argument, or of a (direct, indirect, or virtual) subclass thereof. If object is not an object of the given type, the function always returns False. If classinfo is a tuple of type objects (or recursively, other such tuples) or a Union Type of multiple types, return True if object is an instance of any of the types. |
issubclass() | Return True if class is a subclass (direct, indirect, or virtual) of classinfo. A class is considered a subclass of itself. |
iter() | Return an iterator object. |
len() | Return the length (the number of items) of an object. |
list() | Rather than being a function, list is actually a mutable sequence type |
locals() | Update and return a dictionary representing the current local symbol table. |
map() | Return an iterator that applies function to every item of iterable, yielding the results. |
max() | Return the largest item in an iterable or the largest of two or more arguments. |
memoryview() | Return a “memory view” object created from the given argument. |
min() | Return the smallest item in an iterable or the smallest of two or more arguments. |
next() | Retrieve the next item from the iterator by calling its __next__() method. |
object() | Return a new featureless object. object is a base for all classes. |
oct() | Convert an integer number to an octal string prefixed with “0o”. |
open() | Open file and return a corresponding file object. |
ord() | Given a string representing one Unicode character, return an integer representing the Unicode code point of that character. |
pow() | Return base to the power exp |
print() | Print objects to the text stream |
property() | Return a property attribute. |
range() | Rather than being a function, range is actually an immutable sequence type |
repr() | Return a string containing a printable representation of an object. |
reversed() | Return a reverse iterator. |
round() | Return number rounded to ndigits precision after the decimal point. If ndigits is omitted or is None, it returns the nearest integer to its input. |
set() | Return a new set object, optionally with elements taken from iterable. |
setattr() | This is the counterpart of getattr(). |
slice() | Return a slice object representing the set of indices specified by range(start, stop, step). The start and step arguments default to None. |
sorted() | Return a new sorted list from the items in iterable. |
staticmethod() | Transform a method into a static method. |
str() | Return a str version of object. |
sum() | Sums start and the items of an iterable from left to right and returns the total. |
super() | Return a proxy object that delegates method calls to a parent or sibling class of type. This is useful for accessing inherited methods that have been overridden in a class. |
tuple() | Rather than being a function, tuple is actually an immutable sequence type |
type() | With one argument, return the type of an object. |
vars() | Return the __dict__ attribute for a module, class, instance, or any other object with a __dict__ attribute. |
zip() | Iterate over several iterables in parallel, producing tuples with an item from each one. |
__import__() | This function is invoked by the import statement. |