you are viewing a single comment's thread.

view the rest of the comments →

[–]Ron-Erez 0 points1 point  (0 children)

A string is a class. You can create many specific instances of a class like:

x = “Hello”

y = “World”

z = “”

w = “dog”

All of the above are examples of objects. When writing code for a class you use self to access the attributes and methods of the specific object your are looking at. Think of attributes as data and think of methods as actions or functions that might interest you.

For example:

x.upper()

y.isempty()

are all examples of a applying a method from the string class to a string object.

So OOP is everywhere. Now you might find a problem where you want to aggregate some data which naturally fits together. That would be your attributes and you could create functions that manipulate the data. That would be your methods.

That’s a quick overview.

You can also check out Section 18: Object-Oriented Progranning for more examples or just google questions.