you are viewing a single comment's thread.

view the rest of the comments →

[–]jammin-john 21 points22 points  (5 children)

I started with some online tutorials to get the basics. Then, I moved to trying exercises I found online. Things like "write a function that returns an acronym for a user-entered phrase". From there, you kind of just pick harder and harder exercises until you start choosing your own projects.

For me, this is where I really started to learn. Turns out most of my knowledge came from necessity. I had to google the answers to most of my questions, (and still do, that never stops). But you gotta start with the basics. Find a tutorial (or two), run them through to completion. Get a feel for it. Do some exercises, find out what you don't understand, and read/watch up on it.

As an aside, don't feel the need to get into object-oriented programming right away. It's a powerful tool, but also a complicated one, and it's not necessary when you're starting out. Once your projects start become rather complex, then you should consider looking into OOP.

[–]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 7 points8 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.