This is a post I’ve been trying to write for about 2 weeks now. As some of you might know, I’ve spent the previous weeks studying python and writing small scripts and I’ve decided to write a blog entry about it. As a matter of fact, I’ve also looked over the Pylons framework, but I’ll write about it in a another post. So here it is, my opinion about python alone:
What I like about python
Well, I loooooooooove the indentation. I really do. Python made it impossible for lamers to write ugly “one liners”. Everything must be indented and in its place or it won’t even compile (compiling aka no syntax errors as python is an interpreted language). After years of dealing with ugly sources with no braces, no indentation and so on, this feature is like a gift from heavens for me. I really hope it will catch on and be implemented in other languages.
I also like the
for in iteration over…well…everything. This code:
for item in collection:
…works in most cases, even when collection is a file. In which case the loop iterates over the file’s lines. Tuples, dictionaries and lists are cool features.
What I don’t like about python
Of course, there are some things I dislike about this programming language. The first thing is that sometimes is too verbose. Python doesn’t have an post/pre increment operator. You can’t write
++i, although this code compiles. Further more, it compiles and does nothing, taking the act of debugging to a whole new level of annoyance.
You always have to write
i += 1. It also doesn’t have a ternary operator. If you write
a = (condition) ? b : c it will give you an compiling error.
Another weak point is its OOP capabilities. Object orientated programming is very strangely implemented in python. A class example in python looks something like this:
self.attribute = 'default value'
def custom_method(self, attribute):
self.attribute = attribute
obj = MyClass()
As you can see, there are no access modifiers (private, protected, public), no instantiation operator (new), the this keyword is replaced by self, and you must write it every single time you define a new method in the class. And python also allows multiple inheritance, which does one thing: annoys people.
Apart from some really annoying “features”, I’m starting to like python. It provides a quick way and pretty clean way to do get things done. And in the end, this is all that matters…Python is cool!