Category Archives: Python

Python syntax

Python’s syntax makes it perfect for building simple DSLs for use within your application, thanks to its syntax and metaprogramming features.

We have already specified that Python is totally Object Oriented, this translates into the fact that in Python everything is an object. In this aspect it manages to outclass the language to objects par excellence and that is Java since in Python there is no distinction between basic types and objects, at the same time the object-oriented programming in Python is neither invasive nor annoying, and this is due to its greater purity.

A feature particularly appreciated by Python programmers was the possibility of using so-called blocks that represent an uncommon feature in the most widespread languages and which allow to represent different problems, even very different from each other, with clear and meaningful methods.

The Python is loved, in the same way, by professional programmers who appreciate the most advanced features, and beginners as it is particularly suitable to be learned as a first language.

In fact, thanks to its simplicity, it is possible to learn the basic notions of programming, without having to worry about innumerable conventions and aspects not strictly related to the realization of numerical algorithms.

Moreover Python is effectively expressive in that it provides many built-in data structures and types (the built-in types represent the types already defined in the language); examples are:

  • dict,
  • lists,
  • regexp,
  • whole numbers of arbitrary size.

The Python syntax means that the classes have a very detailed interface, which determines a simplicity in use in common operations.

Python features

The characteristics of Python make it a programming language above all simple, its use is learned in a few days, without presenting great difficulties thanks to a streamlined and very practical syntax; in addition, by presenting a really large number of bookcases included in the distribution and integrated with the installable ones, it is possible, as already anticipated, to realize our programs in a very short time.

Python is particularly dynamic, an example is provided by the fact that the variables can be safely used without the need to declare the type, then the interpreter will be able to identify them; all this, however, without losing precision because operations that are not allowed between different types will cause an error, ie it will never happen, in a more or less hidden way, that a value of a certain type is used as if it were of a different type (strong typing).

Thanks to this, an operation of type 1+ “2” (sum of a number and a string) will cause a runtime error, unlike languages ‚Äč‚Äčlike php or perl that do not allow a similar control.

In Python it is possible to manipulate classes and methods at runtime, ie they can be added, deleted or modified. In this way many of the things that in other languages represent complex structures can in Python constitute simple methods; it is also possible to add custom classes and methods, creating Domain Specific Language (DSL). A Domain Specific Language is a mini-language suitable for a specific problem, the ideal would be to have a language for every purpose, but without the problem of having to learn it from scratch each time.