Page 355 - Beginning Programming with Pyth - John Paul Mueller
P. 355

object.
The main procedure creates two test objects, Value1 and Value2. It adds them together and places the result in Value3. The result is printed onscreen.
2. Click Run Cell.
Figure 15-13 shows the result of adding the two objects together, converting them to strings, and then printing the result. It's a lot of code for such a simple output statement, but the result definitely demonstrates that you can create classes that are self-contained and fully functional.
FIGURE 15-13: The result of adding two MyClass objects is a third object of the same type. Creating a Class
All the previous material in this chapter has helped prepare you for creating an interesting class of your own. In this case, you create a class that you place into an external package and eventually access within an application. The following sections describe how to create and save this class.
Defining the MyClass class
   



























































































   353   354   355   356   357