Python is an object oriented language. You can group code that relates to a particular type of data together into a class, with each piece of code that's defined being a method that can run on the class as a whole, or on a specific set of data (object).
This topic is presented on public course
Python Programming
Examples from our training material
| animal.py | Sample class (exercise) - animal |
| creatures | Exercise answer - program to test class animal |
| drink.py | definition and testing of a class |
| glue | Shows danger of using direct access to a member variable |
| longer | Saving a lambda in a variable and other tricks |
| pets | OO sample - definition and use of two dog objects |
| rr2 | Object equality, identity and sameness |
| wr2.py | Test application for "writer" class |
| wr_test.py | Test harness for writer class |
| writer.py | A simple class - constructor, object method and class method, no inheritance |
Opentalk forum discussions related to this topic
Everything is an objectCommon Python questions
Pictures
Classes in Python
Background information
This module is available under an
Open Training Notes License for free download from
http://www.training-notes.co.uk.
Topics covered in this module
What is Object Orientation and why use it?.
Using Python objects.
Creating your own classes in Python.
Method and variable naming standards.
Including a test harness in your class definition.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our
Listing and schedule page.
Well House Consultants specialise in training courses in
Python,
Perl,
PHP, and
MySQL. We run
Private Courses throughout the UK (and beyond for longer courses), and
Public Courses at our training centre in Melksham, Wiltshire, England.
It's surprisingly cost effective to come on our public courses -
even if
you live in a different
country or continent to us.
We have a technical library of over 600 books on the subjects on which we teach.
These books are available for reference at our training centre. Also
available is the Opentalk
Forum for discussion of technical questions.