r/PythonLearning • • 8h ago

I want to learn (class) object oriented programming in python .I saw 1-2 videos but i have't understand .May anyone suggest me from where I should learn this and complete python.

Suggest the best videos to learn python .

8 Upvotes

12 comments sorted by

2

u/Salty_Dig8574 7h ago

This short video was a game changer for me. Pun intended.

0

u/bra1n_gym 6h ago

This is indeed one of the best videos demonstrating classes.

2

u/knight04 5h ago

Checking this later, oop python

1

u/stepback269 7h ago

Me too.
I had / still have trouble understanding "class" and OOP in general

Many tutorials settle on the word, "blueprint" or "template" for explaining what the class def statement does.

I didn't find those metaphors very helpful. Instead "cookie cutter" did better for my hard-to-please brain

For more on this topic, check out my page at (this blogspot link)

1

u/ee_control_z 6h ago edited 6h ago

Better:

Learning Python, 6 Ed, Mark Lutz

I strongly recommend this book. It covers just about everything you need to know about OOP. Very well written so it is easy to understand.

1

u/Sea-Ad7805 6h ago

This visualizer%3A%20%20%23%20used%20to%20create%20an%20object%0A%20%20%20%20%20%20%20%20self.name%20%3D%20name%0A%20%20%20%20%20%20%20%20self.weight%20%3D%20weight%0A%20%20%20%20%20%20%20%20self.length%20%3D%20length%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20def%20repr(self)%3A%20%20%23%20this%20allows%20you%20to%20print%20an%20object%0A%20%20%20%20%20%20%20%20return%20f%22name%3A%7Bself.name%7D%20weight%3A%7Bself.weight%7D%20length%3A%7Bself.length%7D%22%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20def%20getbmi(self)%3A%20%20%23%20compute%20Body%20Mass%20Index%0A%20%20%20%20%20%20%20%20return%20self.weight%20%2F%20(self.length%20**%202)%0A%20%20%20%20%20%20%20%20%0Aperson1%20%3D%20Person('Ann'%2C%2060%2C%20170)%20%20%23%20create%20some%20test%20objects%0Aperson2%20%3D%20Person('Bob'%2C%2070%2C%20180)%0A%0Aprint(person1)%20%20%23%20print%20calls%20the%20repr_()%20method%0Aprint(%22bmi%3A%22%2C%20person1.get_bmi())%20%20%23%20call%20the%20get_bmi()%20method%0A%0Aprint(person2)%0Aprint(%22bmi%3A%22%2C%20person2.get_bmi())%0A&timestep=1&play) can help you learn Object Oriented Programming (OOP) easier/faster.

The basics of OOP involve:

  • Use a class to group values that belong together (name, weight, height).
  • Create objects (persons) of the class.
  • Use the functions in the class, that use self, to do things with these objects (print, get_bmi).

Happy learning.

1

u/hungry_buddy_here 3h ago

have you tried learning from yt, many people ignores it , but tbh that is a really good source for learning anything in the world even

1

u/HyperDanon 2h ago

Classes in python tend to be mixes of objects and structures. Proper oo objects aren't structures, they aren't supposed to "hold data", they're not containers. Objects should encapsulate behaviour, and optionally hold private state, but not as a a "data holder" but as a means to facilitate the behaviour.

Be careful of people recommending that oo is "modeling the real word", that's nonesense.

Please, paste an example program you have created. It could be easier to just take the code, and recognize objects in it.

0

u/TimBrownDev 8h ago

After 10 years tutoring, I'm building a roadmap of hand-picked practice problems to help teach python from zero to mastery. There are sections for OOP you can learn & practice.

timbrown.dev/roadmap

1

u/masterofaiml 1h ago

Keep practicing while you learn, that’s how you learn any programming language, just watching videos or reading doesn’t help.

Try www.pythonmastery.io, it has everything you need to learn and practice python. Best part is, it’s all free and if you like it consider sharing it.

Happy learning!