7.2. Attribute lookup: the enhanced type model

Viper supports an extension to python in which every object has an associated type object of any kind, possibly itself. When an attribute lookup such as obj.attr fails to find attr in the object by normal means, the search continues in the type object of the object, unless it is itself. If a callable method is found, it is bound to the object.

Note that this lookup mechanism is actually identical to python, except that arbitrary objects can be used as type objects in Viper, whereas Python requires an object of type TypeType. The implication is that the type object can be programmed in python language, rather than C.

The types of system native objects are found indirectly. The hard coded attribute __typename__ has the name of the type object, which is to be found in the module py_types. The type objects are typically classes, since these provide a convenient method of associating methods with the object.