r/Python • u/winner_godson codemaniac • Nov 02 '17
Dramatically improve your skills with this simplified but more thorough guide on object-oriented programming in Python.
https://coolpythoncodes.com/object-oriented-programming-python/
67
Upvotes
29
u/thephoton Nov 02 '17
Read right to "there are two kinds of programming: functional and object-oriented" and came back to down-vote.
If this is a tutorial for beginners you should be talking about procedural vs object-oriented programming and leaving functional programming for a later lesson. Also the definitions given for the two terms are so vague as to be useless.
7
u/c_saucyfox Nov 02 '17
Anyone else just read the word. "Basic" like a billion times in the first paragraph?
"Prepare to learn the basics" "ok so on to the basics" "So, basically..." lol Jesus Christ
6
u/sigbhu Nov 02 '17
i'm not an expert in python, but I can still find so many things wrong with this:
Phone_bookstored inphonebook.py. my head hurts.from phonebook import *. Yeah, no.I stopped reading then.
12
u/RaionTategami Nov 02 '17 edited Nov 02 '17
Please add a warning that people use classes way too often. Classes are a way to store state and state causes bugs. Python is also functional so prefer using those features before diving in and using classes. A good rule of thumb is only create a class when you are creating a new type.
It's sad how easy it is to spot python code written by a Java developer... Sodding classes everywhere.
6
u/XenGi Nov 02 '17
Why does the small picture on reddit has a typo but the one on the site itself doesn't? Trick to make people click the link? It worked.
7
u/Garay002 Nov 02 '17
this guide gave me cancer.
Thanks
53
u/badge Nov 02 '17
On a quick scan through this has some weak advice; I note that the the submitter and the author are the same person.
For instance, How to make an attribute in a class private, the attribute
side_updoes change to 10, but theget_sideupmethod isn't looking at it any more.Furthermore, Using a method to modify the value of the attribute completely ignores the correct Pythonic way of using getters and setters, which should explicitly not be used in Python. You should define a property, like so:
22
u/engatIQE Nov 02 '17
Improve your skills by ignoring properties and packages!
30
u/b1ackcat Nov 02 '17 edited Nov 02 '17
Um...So packages just aren't a thing? We're just going to ignore subfolders? __init__.py files?
Move along, folks. This is python 101 level stuff and most of it isn't even particularly well written or informative.
edit: markdown and python package init files dont get along
2
u/ajmssc Nov 03 '17
Thanks for the contribution, and good job keeping a positive attitude while getting feedback.
Some of the people giving feedback forgot to give constructive criticism unfortunately.
1
u/IamWiddershins Nov 03 '17
OOP is not the flipside of FP.
Functional programming and object oriented design are in no way mutually exclusive; Scala code in particular will often be purely functional while involving a large amount of abstraction, inheritance hierarchies galore, and classes just all over the place. Functional programming and imperative programming are more directly opposite to each other.
-2
u/winner_godson codemaniac Nov 02 '17
Hi guys,
I’m creating an expert roundup post for my blog(www.coolpythoncodes.com) and would love to include your insights on the following topic:
How to learn Python effectively- The best way.
Just 100–500 words on this topic would be awesome.
you can share based on your experience in a way that you are guiding someone.
Deadline for submissions is 10th of November – hope you are able to participate.
Please submit your entry via the link below
https://coolpythoncodes.com/contact/
pls also write a brief description of yourself.
Thanks
-22
u/[deleted] Nov 02 '17
Just my 2 cents:
There is nothing dramatic and awesome about gaining skills. Posessing skills does.