Monthly Archives: November 2021

MODULES AND PACKAGE IN PYTHON

MODULES In Modules and packages in Python, a module represents an organization of code. It is a program that contains the definition of data, functions and classes which become its attributes. A module forms a namespace that occupies an intermediate position in the namespace hierarchy. We have already covered namespaces. A distinction is made between modules and scripts, a script represents the main flow of the program, modules can be considered as object libraries, function containers and classes mainly imported through the import statement in scripts or other modules. IMPORTATION The import takes place via the [...]

By |2022-10-24T23:13:05+02:001 November 2021|0 Comments

ADVANCED TOPICS IN PYTHON

MULTIPLE INHERITANCE In addressing the advanced topics in Python I would say to speak immediately of multiple inheritance, a very important feature. When we talked about inheritance, we saw how a base class can be derived from a superclass. Now we will address the topic of multiple inheritance fully supported in Python, which allows a base class to inherit from two or more classes. The derived class inherits from the two superclasses BClass and CClass. Two integer type attributes have been defined in them. Both attributes are inherited from AClass. Obviously the superclass methods are also [...]

By |2024-08-15T07:26:01+02:005 November 2021|0 Comments

DATA CLASSES IN PYTHON

Before addressing the topic "The Data Classes in Python" it is necessary to make a small introduction on what are the Type Annotations. TYPE ANNOTATIONS Annotations are Python features that suggest to developers the data types of function variables or parameters and the return type. There are mainly two types of annotations in Python: function annotations and variable annotations. The syntax for the function annotation is shown below: def func(a: <expression>, b: <expression>) -> <expression>:     pass Examples of function and variable annotations are shown in the code below. It is important to underline that even the classes as [...]

By |2024-08-14T04:08:27+02:007 November 2021|0 Comments

NEWS INTRODUCED IN PYTHON 3.8 AND 3.9

ASSIGNEMENT EXPRESSION Let's start to deepen the topic "NEWS INTRODUCED IN PYTHON 3.8 AND 3.9" starting from a feature introduced in Python 3.8. A new operator has been introduced, it is called Walrus Operator and it is an assignment operator. Its symbol is: :=.  Before talking about this new operator let's do a little review on the expressions. An expression is a particular type of Statement evaluated at runtime to produce a value. The simplest expressions are literals and identifiers. You can create other expressions using the operators that Python makes available to us, moreover the [...]

By |2024-08-14T15:35:16+02:009 November 2021|0 Comments

NEWS INTRODUCED IN PYTHON 3.10

PYTHON INSTALLATION 3.10 Before tackling the "the pattern matching" topic, let's talk about installing Python 3.10. Download the program from the python.org site and install it either in the folder that is automatically proposed to you, or you can decide on a different installation directory. Once the program is installed, configure the system environment variable Path by setting the path of the Python 3.10 installation directory. Restart your computer and everything should be fine. Open a Python schell to see if the current version is 3.10. PATTERN MATCHING The pattern matching is the main feature added in Python 3.10. [...]

By |2022-10-24T23:29:00+02:0011 November 2021|0 Comments

PYTHON AND RABBITMQ

CLIENT SERVER ARCHITECTURE Before addressing the topic "Python and RabbitMQ" let's talk a little about architectures by introducing the client-server model and distributed architectures. THE CLIENT Client software is generally of limited complexity, normally limited to operating as an interface to the server. In general, in the IT field, the term client indicates a component that accesses the services or resources of another component, called a server. In this context we can therefore speak of clients referring to hardware or software. A computer connected to a server via a local or geographic network, and to which it requests one [...]

By |2022-10-27T21:36:51+02:0014 November 2021|0 Comments

PYTHON AND MONGODB

PYTHON AND MONGODB Let's start talking about "Python and MongoDB". The traditional model for representing data in a database is the relational model. In this article we will take as an example a new data representation model that does not use the relational model and the SQL language to query it but a totally different approach based on MongoDB. JSON JSON (Javascript Object Notation) is a lightweight data representation and interchange format. It is based on a subset of the javascript programming language. JSON is built starting from two basic structures, practically present in all programming [...]

By |2022-10-24T23:44:12+02:0017 November 2021|0 Comments
Go to Top