Objects
In this lesson, we will look at several different types of objects.
We'll cover the following
Object notation
Lists and strings (which you have already seen) and sets and dictionaries (which are coming up soon) are objects. There is special terminology for talking about objects:
- A method is a function defined on an object.
- You don’t “call” methods. You send messages to an object. This is unwieldy, so I like to say you talk to objects.
Along with this, there is a special notation for using objects:
- Name the object you are talking to.
- Put a period (
.
). - Write the method name, along with any arguments (comma separated and in parentheses).
For example, if s
is the string Hello World
, then s.lower()
is the string hello world
. You can think of this as saying, “Hey s
, give me a lowercase version of yourself.”
Create a free account to view this lesson.
By signing up, you agree to Educative's Terms of Service and Privacy Policy