Saying hello to Python: observations from a newbie


The last few weeks i’ve been dabbling around with Python. I’m busy doing some experiments with OpenCV, and because it has Python bindings it seemed like a good excuse to dive a little bit more into Python.

Here are some of my observations, from somebody with a background in mostly frontend jobs, usually Javascript/Node.js and/or PHP.


Could be better

Here’s an example. Let’s say i want to know how to do the Python equivalent of PHP’s foreach. The docs about the for statement say this:

The for statement is used to iterate over the elements of a sequence (such as a string, tuple or list) or other iterable object:

for_stmt ::=  "for" target_list "in" expression_list ":" suite
      ["else" ":" suite]

Right, so what does that mean? What’s ::=? What’s an ‘expression list’?

The expression list is evaluated once; it should yield an iterable object. An iterator is created for the result of the expression_list. The suite is then executed once for each item provided by the iterator, in the order of ascending indices.

“Ascending indices”? “Suite”? This might be clear for a CI professor, but it’s not for the mere mortals that read the docs and want to get stuff done.

And after reading this section i still don’t know how to do foreach in Python :(

Nice that the search works on the offline download though.

So, that’s my list. What are the things you like and hate about Python?

If you like this post, why not give a vote on Hacker News?

Add a comment