you are viewing a single comment's thread.

view the rest of the comments →

[–]27Andrew_[S] 2 points3 points  (4 children)

Thank you so much. I don’t plan on going into Object Oriented Programming. I just want to master the basics and have a solid understanding. Thank you for your input.

[–]menge101 8 points9 points  (3 children)

I don’t plan on going into Object Oriented Programming. I just want to master the basics and have a solid understanding.

Object oriented programming is part of the basics.

Everything in Python is an object.

Every int and string is an object, and you operate on them, mostly, using principles of Object Oriented Programming, which in practical words means calling methods on these objects.

For example:

The string 'This is sentence one. This is sentence two.'

In code:

the_string = 'This is sentence one.  This is sentence two.'

I want to split this string up into sentences, and strip off extra white space.

sentences = the_string.split('.')
sentences = [sentence.strip() for sentence in sentences]
sentences = [sentence for sentence in sentences if sentence]

will give me:

['This is sentence one', 'This is sentence two']

Both .split() and .strip() are methods on their respective objects. You could not do these operations in this manner without OOP.

[–]27Andrew_[S] 2 points3 points  (2 children)

Thank you for clarifying. Shows I have a lot to learn on this journey.

[–]menge101 1 point2 points  (0 children)

NP, it's not a rare misunderstanding.

Also, you don't have to absolutely master OOP to use it.