Files
practical-python/Notes/04_Classes_objects/00_Overview.md
2020-05-25 12:40:11 -05:00

782 B

Overview

Object Oriented (OO) programming

A Programming technique where code is organized as a collection of objects.

An object consists of:

  • Data. Attributes
  • Behavior. Methods, functions applied to the object.

You have already been using some OO during this course.

For example with Lists.

>>> nums = [1, 2, 3]
>>> nums.append(4)      # Method
>>> nums.insert(1,10)   # Method
>>> nums
[1, 10, 2, 3, 4]        # Data
>>>

nums is an instance of a list.

Methods (append and insert) are attached to the instance (nums).

Summary

This will be a high-level overview of classes.

Most code involving classes will involve the topics covered in this section.

If you're merely using existing libraries, the code is typically fairly simple.