print
__build_class__
id
input
repr
iter
next
round
enumerate
range
zip
globals
locals
alllocals
len
copyright
exit
isinstance
eval
super
getattr
setattr
iscallable
reverse
isiter
min
max
map
abs
method
classmethod
staticmethod
property
getannotation
sum
hasattr
dir
bin
hex
ord
chr
unicode_name
compile
Exception
TypeError
ValueError
AttributeError
KeyError
NameError
IndexError
MemoryError
RecursionError
StopIteration
FileNotFoundError
InvalidOperationError
ImportError
KeyboardInterrupt
AssertionError
ZeroDivisionError
OverflowError
NotImplementedError
Print objects with specified seperator and end.
print(..., sep=' ', end='\n', file=sys.stdout)
Argument | Information |
---|---|
... |
objects to print |
sep |
object to print that seperates objects |
end |
object to print last |
file |
file-like object to print to |
Calls __str__
on all objects passed before printing.
None
Get __repr__
of an object
repr(object)
Argument | Information |
---|---|
object |
object to get __repr__ of |
Calls __repr__
on object passed.
Return value from __repr__
method call.
Build a class (type
) from provided parameters.
__build_class__(doc, bases, name, func)
Argument | Information |
---|---|
doc |
Docstring |
bases |
Bases to inherit from (left -> right increasing in inheritance level) |
name |
str object for name |
func |
function object for class body |
func
parameter is called, and resulting local variables are static variables for the generated class.
Return generated type
Type object.
There are 2 possible argument lists that may be passed in different scenarios:
type(object)
Get the type of an object
Argument | Information |
---|---|
object |
Object to get type of |
type(name, bases, dict)
Generate a new type from arguments. Dissimilar to __build_class__
because it takes a dict
argument directly. __doc__
will be set to None
.
Argument | Information |
---|---|
name |
str object that is the name of new type |
bases |
tuple or list object to be the bases of the new type |
dict |
dict object to __dict of the new type |
Returns a type object.
Create a new int
object.
int(object, base=10)
Argument | Information |
---|---|
object |
object to convert to int |
base |
int object to interpret the base of the passed arugment object as |
Calls __int__
on object passed.
Return value from __int__
method call.
Create a new str
object.
str(object)
Argument | Information |
---|---|
object |
object to convert to str |
Calls __str__
on object passed.
Return value from __str__
method call.
Create a new dict
object.
dict(iterator)
Argument | Information |
---|---|
iterator |
iterable that returns 2 values per __next__ call |
During the iteration over iterator
, the first return value is the key, the second is the value.
New dict
object.
Create a new list
object.
list(iterator)
Argument | Information |
---|---|
iterator |
object to iterator over to construct list |
None
New list
object.
Create a new tuple
object.
tuple(iterator)
Argument | Information |
---|---|
iterator |
object to iterator over to construct tuple |
None
New tuple
object.
Create a new object
object.
object()
None
None
New object
object.
Get memory address of object.
id(object)
Argument | Information |
---|---|
object |
object to get address of |
None
int
object containing the address
Get user input and print a prompt.
input(prompt)
Argument | Information |
---|---|
prompt |
prompt to print |
Calls __str__
on prompt before printing.
str
object containing the user input.
Open a file.
file(name, mode, encoding='UTF-8')
Argument | Information |
---|---|
name |
str object containing name of file to open |
mode |
str object containing mode to open the file in |
encoding |
str object containing encoding that data will be converted to before being written to the file, if the mode is non-binary |
None
Open file
object.
Create a new float
object.
float(object)
Argument | Information |
---|---|
object |
object to convert to float |
Calls __float__
on object passed.
Return value from __float__
method call.
Attempt to create an iterator
iter(iterator)
Argument | Information |
---|---|
iterator |
object that defines __iter__ |
Calls __iter__
on object passed.
Return value from __iter__
method call.
Get next value from an iterator
next(iterator)
Argument | Information |
---|---|
iterator |
object that defines __next__ |
Calls __next__
on object passed.
Return value from __next__
method call.
Create slice object, used to slice iterators
slice(start, stop, step)
Argument | Information |
---|---|
start |
int start position or None |
stop |
int stop position or None |
step |
int step |
None
New slice
object
Create a new bool
object.
bool(object)
Argument | Information |
---|---|
object |
object to convert to bool |
Calls __bool__
on object passed.
Return value from __bool__
method call.
Round an object.
round(object, digits=0)
Argument | Information |
---|---|
object |
object to round |
digits |
no. of digits after decimal to round to |
object
parameter must define __float__
Return rounded value as float
object.
Create an enum
object.
enumerate(iterator)
Argument | Information |
---|---|
iterator |
iterator |
iterator
parameter must define __iter__
Return new enum
object.
Create an range
object.
range(start)
range(start, stop, step=1)
Argument | Information |
---|---|
start |
int object for start value |
stop |
int object for stop value |
step |
int object for step value |
None
Return new range
object.
Create an zip
object.
zip(...)
Argument | Information |
---|---|
... |
objects that are iterables |
None
Return new zip
object.
Get globals dict
.
globals()
None
None
Return a dict
containing the globals.
Get globals dict
.
locals()
None
None
Return a dict
containing the scope's locals.
Get globals dict
.
alllocals()
None
None
Return a list
of dict
containing all scope's locals and the globals.
Terminate program.
exit()
None
None
Return None
.
Get copyright information.
copyright()
None
None
Return str
that is the copyright information.
Get length of an iterator
len(iterator)
Argument | Information |
---|---|
iterator |
iterator |
Calls __len__
on object passed.
Return value from __len__
method call.
Check if an object is an instance of another.
isinstance(object, type)
Argument | Information |
---|---|
object |
object to check instance |
type |
type object to check if instance of |
None
Return bool
True
if object
is an instance of type
, otherwise False
Evaluate code snippet.
eval(snippet, globals={}, locals={})
Argument | Information |
---|---|
snippet |
str object containing code snippet |
globals |
dict that is globals for execution |
locals |
dict that islocals for execution |
None
Return None
Create proxy object.
super(object)
Argument | Information |
---|---|
object |
object to create proxy of |
None
Return super
object.
Get attribute of an object.
getattr(object, attr)
Argument | Information |
---|---|
object |
object to create proxy of |
attr |
str attribute |
None
Return attribute object.
Set attribute of an object.
setattr(object, attr, val)
Argument | Information |
---|---|
object |
object to create proxy of |
attr |
str attribute |
val |
value to set |
None
Return None
Get absolute value of an object.
abs(object)
Argument | Information |
---|---|
object |
object to get absolute value of |
Calls __abs__
on object passed.
Return value from __abs__
method call.
Check if an object is callable.
iscallable(object)
Argument | Information |
---|---|
object |
object to check if callable |
Checks __call__
method.
Return True
if the object is callable, otherwise False
Reverse a sequence.
reverse(seq)
Argument | Information |
---|---|
seq |
sequence to reverse |
seq must define __get__
.
Return new list
Check if an object is iterable.
isiter(object)
Argument | Information |
---|---|
object |
object to check if callable |
Checks __iter__
method.
Return True
if the object is iterable, otherwise False
Get the minimum value in an iterator.
min(iterator)
Argument | Information |
---|---|
iterator |
iterator to get minimum value from |
None
Return minimum value.
Apply mapping to iterators
map(func, ...)
Argument | Information |
---|---|
func |
mapping to apply |
... |
iterators |
None
Return map
object.
Create new method
.
method(func, instance)
Argument | Information |
---|---|
func |
function to wrap |
instance |
instance of object that contains the func |
None
Return method
object.
Create new classmethod
, supposed to be used as a decorator.
classmethod(func)
Argument | Information |
---|---|
func |
function to wrap |
None
Return classmethod
object.
Create new staticmethod
, supposed to be used as a decorator.
staticmethod(func)
Argument | Information |
---|---|
func |
function to wrap |
None
Return staticmethod
object.
Create new property
to intercept get/set and deletion of an attribute.
property(get=None, set=None, del=None)
Argument | Information |
---|---|
get |
getter function |
set |
setter function |
del |
deleter function |
None
Return property
object.
Get annotation from current scope.
getannotation(name)
Argument | Information |
---|---|
name |
name to get annotation of |
None
Return annotation.
Create a set from an iterator.
set(iterator)
Argument | Information |
---|---|
iterator |
iterator |
Iterator must define __iter__
method.
Return new set
.
Check if an object has the specified attribute.
hasattr(object, attr)
Argument | Information |
---|---|
object |
object to check instance |
attr |
str attribute |
None
Return bool
True
if object
has the attribute, otherwise False
.
Create a bytes object from an iterator.
bytes(iterator)
Argument | Information |
---|---|
iterator |
iterator |
Iterator must define __iter__
method.
Return new bytes
.
Calculate the sum of the values in an iterator.
sum(iterator)
Argument | Information |
---|---|
iterator |
iterator |
Iterator must define __iter__
method.
Return the sum.
Get the keys of the __dict__
of an object, or the keys of locals().
dir(object)
- Default
dir()
- Get the keys of locals().
Argument | Information |
---|---|
object |
object to get __dict__ . |
None
Return new list
.
Get the binary representation of an int.
bin(object)
Argument | Information |
---|---|
object |
int object to get binary representation of |
None
Return new str
.
Get the hexadecinal representation of an int.
hex(object)
Argument | Information |
---|---|
object |
int object to get hexadecimal representation of |
None
Return new str
.
Convert unicode code point value to string.
chr(object)
Argument | Information |
---|---|
object |
int object that is the code point |
None
Return new str
.
Get the ordinal value (unicode code point) of a str
of length 1.
ord(object)
Argument | Information |
---|---|
object |
str object that has a length of 1 |
None
Return new int
.
Get the unicode name of an ordinal value.
unicode_name(object)
Argument | Information |
---|---|
object |
int object that is the code point |
None
Return new str
that is the name.
Create a bytearray object from an iterator. The bytearray object is a mutable version of the bytes object.
bytearray(iterator)
Argument | Information |
---|---|
iterator |
iterator |
Iterator must define __iter__
method.
Return new bytearray
.
Type of a function. The function
type has the following "special" attributes:
__annotations__
__doc__
__args__
__defaults__
function(name, code, globals)
Argument | Information |
---|---|
name |
name of function |
code |
code object for function |
globals |
globals to use during execution of function |
None
Does not return.
Compile code snippet.
compile(snippet, name)
Argument | Information |
---|---|
snippet |
str object containing code snippet |
name |
str object contaiing the name for the code snippet |
None
Return code
object