Friday, June 19, 2015

Controlling Attribute Access With Properties

Properties allow indirect access to private attributes. See example below. The private attribute _name is allowed to be access through a property.


Wednesday, June 17, 2015

Sunday, June 14, 2015

Creating and Accessing Attributes

The constructor method in this program has the attribute of name. The __str__() method creates a string representation of the object. See different ways to access attributes in the program below.



Constructor Method

A constructor is a method that is invoked automatically when a new object is created.

Creating Class, Method, and Objects

This simple program creates a class (virtual_pet), object (pet1), method (talk).