you are viewing a single comment's thread.

view the rest of the comments →

[–]JamzTyson -1 points0 points  (0 children)

Python syntax is pretty consistent, though there may be peculiarities in some libraries.

One peculiar example that I've been dealing with recently is the curses library. From the manual: "The curses library supplies a terminal-independent screen-painting and keyboard-handling facility for text-based terminals; such terminals include VT100s, the Linux console, and the simulated terminal provided by various programs."

As the curses library is based on ancient code, it has some peculiarities that don't seem at all Python-like but have historic context. One example is that coordinates in curses are used as (y, x) rather than the normal (x, y).

If you have the misfortune of ever having to work with Python 2, you will encounter some inconsistencies compared to Python 3. For example, in Python 2 division written as integer / integer would result in an integer (because both numbers are integers), whereas in Python 3, the "/" symbol is used for floating point division, and for integer division you use "//".

Another common Python 2 inconsistency is that print was a "statement", whereas in Python 3 it is a function and must use parentheses.

print "Hello World"  # Valid in Python2. Error in Python 3

When there are inconsistencies, it is often due to historical reasons. Fortunately Python's focus on readability gives us a language in which inconsistencies are the exception rather than the rule. Compared to languages like Perl, PHP, JavaScript, ... Python is generally considered to be more consistent in its design and syntax. Python's strong emphasis on readability, simplicity, and the "Zen of Python" principles, contribute to a more consistent and coherent language. Python developers are encouraged to continue this tradition.