4.7. Type Factory FunctionsSince Python 2.2 with the unification of types and classes, all of the built-in types are now classes, and with that, all of the "conversion" built-in functions like int(), type(), list(), etc., are now factory functions. This means that although they look and act somewhat like functions, they are actually class names, and when you call one, you are actually instantiating an instance of that type, like a factory producing a good.
The following familiar factory functions were formerly built-in functions:
Other types that did not have factory functions now do. In addition, factory functions have been added for completely new types that support the new-style classes. The following is a list of both types of factory functions:
|