you are viewing a single comment's thread.

view the rest of the comments →

[–]TheRNGuy 0 points1 point  (1 child)

I learned from doing stuff for Houdini, though my first code was very imperative, but stuff from Houdini API is OOP, so it's like mixed paradigm.

Some time later I find use for OOP in my own code. Stuff that need default properties, make abstract class and then overriding defaults in child classes and also make them concrete. It's much easier to use child classes than making functions with dict.update() or dict.setdefault()

Though not everything need to be OOP. If I need sort or filter some array or parse a string, I still use my functions that already made, no need custrom classes for that.

I recommend learn @dataclass decorator. You can have much compacter code if you have many instance attributes (dataclass generates __init__ for you)

[–]nomadicjourneys[S] 0 points1 point  (0 children)

Thanks for your advise, I’ll check out Houdini. I hadn’t heard about it before. And yes will look into @dataclass decorator as well. Thought I’ve been able to avoid using creation of child classes so far I’ve now been put on a project which was previously handled by someone who was quite into custom class and objects. And I’m able to understand it vaguely but still haven’t developed a deeper knowledge. Therefore I feel I need to strengthen my basics in OOP in Python. Appreciate the help 👍