Python Notes and Examples


Calling type(foo) returns the actual class object of which foo is an instance (that is, not foo’s class’s name (a string), but rather the actual class, which is itself an object).

Note that although you usually capitalize the names of your own types/classes, by Python convention those built-in types above are all named lowercase.

Ints automatically widen to floats. To convert between other types, pass the object to the new type’s constructor.