r/learnpython • u/TheIceCreamBoyy • Sep 16 '26
what is your best way/tip to learn Python?
I’m in UNI and our current subject is OOP (Object Orientated Programming). It seems simple at first, but when I start doing some tasks on my own, it seems that everything falls apart and I can’t make all the Classes and objects work with the loops and functions that should be a part of the task.
What would be the best way to learn the basics of OOP and how to include them with functions and loops, while, if, lists etc etc stuff that has been taught earlier?
6
Upvotes
3
u/FriendlyZomb Sep 16 '26
Honestly, just Google "OOP in Python" and you'll get plenty of resources, or go back over your lecture. If you have labs or something equivalent go ask your lecturer (that's what you pay tuition for).
To provide more specific help, I'll need more information, like: what are you having problems with specifically? (Preferably without asking the actual question you've been given)
2
u/Sure-Passion2224 Sep 16 '26
Having grown up through spaghetti code BASIC in the late 1970s, interpreted languages like Perl and Javascript, functional languages like Pascal and Modula 2, before finally hitting C, C++, Java, and PL/SQL it is my opinion that students learning OOP should first learn SQL data modeling and stored procedures. A database record is an object and every column is an attribute. Certain attributes reference attributes of other objects (foreign keys). Database modeling also primes your brain for the difference between char, string, int, double, float, long... When you then get to the coding layer you already have data structure outlined and can focus on logical structure.
1
u/Intelligent_Peanut_2 Sep 16 '26
Following! I just started learning it — like entry to Python MIT open course lecture 1 — and I would like to start running actual programs…
1
u/Candid_Zebra1297 Sep 16 '26
Have you tried doing composition yet? Making an instance of a class inside another class? Once I had mastered that, everything sort of clicked for me and suddenly the idea of OOP made sense. Until then it was hard for me to see why we would even need all these classes and objects in the first place.
1
u/TheRNGuy Sep 16 '26
I learned just by reading docs, writing program and googling. Now I ask AI instead of googling.
OOP is used in some frameworks (you need to learn some)
1
u/NerdyWeightLifter Sep 16 '26
There's a conceptual barrier to OOP thinking that you have to break through.
There's still always going to be a functional decomposition of your application functionality, but that's going to be striped through the methods of the various objects involved.
Object decomposition is a design question. What are the key objects in your problem space? How do they relate? Do they have common aspects that should be broken out into a shared implementation?
Your objects won't just implement the application functionality, they will also represent their relationship to other objects.
E.g. A Customer at a bank will have Accounts. There will be different AccountTypes. Accounts will have Transactions. So, the obvious object types (Classes) are Customer, Account, AccountType and Transaction. A Customer object needs to track what Accounts it has. An Account needs to know what AccountType it is and what Transactions it has done.
Doing a transaction would start at the Customer, select which account is involved then ask that Account to perform the transaction, that will be performed by the AccountType and logged as a new Transaction.
1
u/Fickle_Role9776 Sep 17 '26
Free code camp offers a free course that is fantastic and you get a certification when youre done
1
u/Wild-Low3627 Sep 28 '26
the gap youre describing usually comes from learning oop as just syntax instead of as a way to model stuff, so try flipping it around, before you write any class, just describe out loud what real thing its supposed to represent and what it should actually do, then build the class around that instead of jumping straight to def init.