September 2013
Intermediate to advanced
350 pages
9h 38m
English
In Importing Modules, we saw that a module is a kind of object, one that can contain functions and other variables. There is another kind of object that is similar to a module: a class. You’ve been using classes all along, probably without realizing it: a class is how Python represents a type.
You may have called built-in function help on int, float, bool, or str. We’ll do that now with str (notice that the first line says that it’s a class):
| | >>> help(str) |
| | Help on class str in module builtins: |
| | |
| | class str(object) |
| | | str(object[, encoding[, errors]]) -> str |
| | | |
| | | Create a new string object from the given object. If encoding or |
| | | errors is specified, then the object must expose a data buffer |
| |
Read now
Unlock full access