18.5. Discussion

Now, that we have seen many aspects of Python, what are its main characteristics? What causes the language to be very expressive and easy to learn? Are these properties related to the bad performance and dangerous "openess" of the langage?

Variables don't have to be declared, and you can assign anything to a variable. This is one of the features which make life very convenient in the beginning, but may cause trouble for large systems. Not requiring variables to be declared saves typing, but can turn simple typos into hard-to-find bugs. It is difficult to automatically optimize Python programs (e.g., using a just-in-time compiler), because a variable may contain any type of object, and the type can change during the execution of the program.

Python has no concept of an "interface", that is a declaration of of a function or class without an implementation. This makes large scale development harder, since you only find out at runtime if an object has the expected attributes and methods. In this sense, Python's object orientation is very similar to Smalltalk.

Without interfaces, it is almost impossible to define APIs precisely. Most of Python's standard APIs are nonetheless quite easy to learn, but it all depends on conventions and good documentation. The definition of complex APIs such as database access has definitely suffered from the lack of interfaces. Not surprisingly, the probably most complex Python application, the web publishing (content management) systen Zope has introduced its own concept of interfaces.

Python strongly distinguished statements (e.g., control statements) and expressions. Statements don't represent a value. This prevents a more functional programming style in some situations. For example, there is no "functional if" statement such as the question operator in C. Ideally one would like to write

>>> y = if x < 0 then -1 else 1
SyntaxError: invalid syntax

but this is unfortunately not valid Python code (Ruby does better in this area).