Standard Type Built-in Functions
Along with generic operators which we have just seen, Python also provides some builtin functions that can be applied to all the basic object types: cmp(), repr(), str(), type(), and the single reverse or back quotes ( ” ) operator, which is functionally equivalent to repr().
Operator | function |
---|---|
cmp(obj1, obj2) | compares obj1 and obj2, returns integer i where: i < 0 if obj1 < obj2i > 0 if obj1 > obj2i == 0 if obj1 == obj2 |
repr(obj)/’ obj’ | returns evaluatable string representation of obj |
str(obj) | returns printable string representation of obj |
type(obj) | determines type of obj and return type object |