ABSTRACT

As mentioned in the introduction of the book, Python is an object oriented language. Unlike other languages that handle objects, Python allows us to program in a classic procedural way, without considering the objects paradigm. Sometimes this is called “multi-paradigm language.” Although this makes it easy to start programming, in the long run it can tempt the programmer not to take advantage of all the possibilities that Python offers. We already used objects, even without stating it in an explicit way. Data

types included in Python are objects. A string, a dictionary and a list, are implementation of objects. Each of them has its associated functions (methods in the jargon) and its attributes. We have seen that lower() returns a string in lower case, this is because all the objects of the class string have the method lower() associated with them. The same is true for other types of data that are included in Python. A class can be used to define a data type. Although data types included

in Python are many and varied, its capacity to include all our information modelling needs is limited. One of the goals of programming is to represent the real world. We can use a dictionary to represent a translation table between nucleotides and amino acids, a string to represent a DNA sequence or a tuple to represent the space coordinates of an atom in a protein. But, what data type do we use to represent a metabolic state of a cell? The different domains in a protein? The result of a BLAST run? What about an ecosystem? There is a need for the ability to define our own data types, to be able

to model any system, either biological or of any other type. Although the functions are useful to modularize the code, they are not designed to fulfill this role. The functions cannot store states, since the values of variables only have life while the function is being executed. Other languages have their personalized data types, like “structs” in C or “record” in Pascal, but they do not have the same flexibility as the objects of languages based on OOP be

The world of OOP has its own vocabulary. In this section I will try to clarify a few of the many new words such as class, method, instance, attributes, polymorphism, inheritance, etc. The definitions will not be exhaustive. Some of them will not even be exact, but the priority will be the understanding of the subject rather than being overly formal. Let’s remember that the objective of this book is to provide programming tools to solve biological problems. Keeping this in mind, the following definitions and their respective examples have been written.