-
Book Overview & Buying
-
Table Of Contents
Python Object-Oriented Programming - Fifth Edition
By :
Before we can look closely at creating classes, we need to talk a little bit about what a class is and how to be sure we’re using it correctly. One central idea is everything in Python is an object.
When we write literal values such as "Hello, world!" or 42, we’re actually creating objects that are instances of built-in classes. (Some languages have “primitive types” which aren’t objects; Python doesn’t have this complication.) We can fire up interactive Python and use the built-in type() function on the class that defines the properties of these objects:
>>> type("Hello, world!")
<class ’str’>
>>> type(42)
<class ’int’>The point of object-oriented programming is to solve a problem via a collaboration of objects. When we write 6 * 7, the multiplication of the two...