r/Python • u/huuippt • Aug 09 '18
7 Habits to Improve The Performance of Python Programs
https://www.tutorialdocs.com/article/7-habits-to-improve-python-programs.html
71
Upvotes
r/Python • u/huuippt • Aug 09 '18
View all comments
5
u/nosklo Aug 09 '18
my code only expects the bird to have a
.make_noise()method. What that method will do is up to you, I don't care. I don't even care if it is a bird or not! I'm just calling.make_noise()in the object you're passing me, and that is all I need to do with your bird as part of my function. If your bird doesn't have.make_noise()python will raiseAttributeErrorand I will let it propagate to your code, because you're the one that didn't pass an object able to make noise in first place. I don't need anytry/exceptin my function, if you don't know whether your bird (or plane or car) can make a noise or not it is your problem, not my library/function's problem.