Showing posts with label method. Show all posts
Showing posts with label method. Show all posts

Tuesday, August 4, 2015

Module Creation

This is an example of a module. Modules are meant to be imported into another program and used, not run stand alone.



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).

Monday, October 13, 2014

Creating and Importing Modules

A module can be used to save variables and methods. Modules can then be imported into a method. See example below.




Constructors

A constructor is a function that initializes immediately as soon as the objects is created. See example below.