December 2000
Intermediate to advanced
816 pages
16h 57m
English
Along with generic operators which we have just seen, Python also provides some built-in 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().
| function | operation |
|---|---|
| cmp(obj1, obj2) | compares obj1 and obj2, returns integer i where:
i < 0 if obj1 < obj2 i > 0 if obj1 > obj2 i == 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 |
The cmp() built-in function CoMPares two objects, say, obj1 ...
Read now
Unlock full access