OOP: Using Objects

Python supports Object-Oriented Programming (OOP), and strings in Python are actually objects. We'll just touch on this concept now and return to it later in the course.

OOP allows programmers to define classes that template the data and behavior of objects.

  • An object is referred to as an instance of a particular class.

    • For example, the string literal "Mary Lyon" is an instance of the str class.

  • Data can be associated to a particular instance and is called its instance properties.

  • Behavior can be associated to a particular instance and is called its instance methods.

For right now, what's important is that we use the following syntax to "ask" an object to perform an instance method. This will look a lot like invoking a function, but it uses the dot . notation to address the particular object.

*instanceName*.*methodName*( *parametersToPass* )

We'll see some examples with string objects, which will make this more concrete!