I sometimes heard claims such as “shell scripting is no more necessary since now we have Python“, or “I don’t like Python, I can do everything with shell scripts“.

Both of the above claims are too simplistic: skilled professionals that know both of them for true know also that they both have pros and cons. So the right approach probably is to use the one that best fit the use case in terms of delivery time and maintainability.

For example:

  • if the use case is housekeeping of files and directories, or automating tasks that run a lot of shell commands, a shell script certainly wins over a Python script in terms of delivery time
  • when it comes to data search and manipulation, in simplest use cases may be still convenient to use shell scripting, but when complex formats such as JSON, XML or YAML are involved, it is certainly more effective to develop using Python
  • the same applies when developing scripts that connect to REST API: it is straightforward that Python is the best choice

So, to keep it short, professionals should know both shell scripting as well as Python, so to pick the right one for the particular use case they are working onto.

This is the first of a set of three posts aimed at showing how to create a full featured Python3 project: since the topic is quite massive, I decided to split it into three different posts. In this post we do not only quickly see how to develop a full featured Python application, since I wanted to do something that shows a lot of things, such as:

  • creating Python objects
  • put the custom Python objects inside a Python package within the scope of our own namespace
  • develop accordingly to encapsulation rules, by implementing getters and setters methods that look like regular attributes by exploiting decorators
  • use the standard Python logging facility, configuring everything with an external settings file
  • altering the __eq__ comparison so to consider two objects as equal when one of their attribute has the same value
  • implementing comparison methods and the __iter__ method, so to be able to use Python standard functions such as sorted() to sort it also in reverse order
  • exploit total_ordering to make an object fully sortable

The next parts of this post will be on the following topics

The operating environment used in this post is Red Hat Enterprise Linux 8 or CentOS 8 - using a different environment may lead to having to adapt or even change things.

Read more >