Table of Content

Python 3.11.4 documentation



Release: 3.11.4
Date: July 11, 2023
Author: Pablo Galindo Salgado

This article explains the new features in Python 3.11, compared to 3.10.

Download the latest version for Windows


Installing Python Module


As a popular open-source development project, Python has an active supporting community of contributors and users that also make their software available for other Python developers to use under open-source license terms.

This allows Python users to share and collaborate effectively, benefiting from the solutions others have already created to common (and sometimes even rare!) problems, as well as potentially contributing their own solutions to the common pool.

Note: For corporate and other institutional users, be aware that many organizations have their own policies around using and contributing to open-source software. Please take such policies into account when making use of the distribution and installation tools provided with Python.


Key Points



pip is the preferred installer program. Starting with Python 3.4, it is included by default with the Python binary installers.

A virtual environment is a semi-isolated Python environment that allows packages to be installed for use by a particular application, rather than being installed system-wide.

venv is the standard tool for creating virtual environments and has been part of Python since Python 3.3. Starting with Python 3.4, it defaults to installing pip into all created virtual environments.

The Python Package Index is a public repository of open-source licensed packages made available for use by other Python users.

the Python Packaging Authority is the group of developers and documentation authors responsible for the maintenance and evolution of the standard packaging tools and the associated metadata and file format standards. They maintain a variety of tools, documentation, and issue trackers on both GitHub and Bitbucket.

distutils is the original build and distribution system first added to the Python standard library in 1998. While direct use of distutils is being phased out, it still laid the foundation for the current packaging and distribution infrastructure, and it not only remains part of the standard library, but its name lives on in other ways (such as the name of the mailing list used to coordinate Python packaging standards development).


Basic usage


The standard packaging tools are all designed to be used from the command line.

The following command will install the latest version of a module and its dependencies from the Python Package Index:

bash
python -m pip install SomePackage

Note: For POSIX users (including macOS and Linux users), the examples in this guide assume the use of a virtual environment.
For Windows users, the examples in this guide assume that the option to adjust the system PATH environment variable was selected when installing Python.

Normally, if a suitable module is already installed, attempting to install it again will have no effect. Upgrading existing modules must be requested explicitly:

bash
python -m pip install --upgrade SomePackage

Python Syntax compared to other programming languages


Python was designed for readability, and has some similarities to the English language with influence from mathematics.

Python uses new lines to complete a command, as opposed to other programming languages which often use semicolons or parentheses.

Python relies on indentation, using whitespace, to define scope; such as the scope of loops, functions and classes. Other programming languages often use curly-brackets for this purpose.

Python tutorial


First, we download pycharm, an IDE.
An IDE (Integrated Development Environment) is software that combines commonly used developer tools into a compact GUI (graphical user interface) application.


To get started with PyCharm, let’s write a Python script.

1. If you’re on the Welcome screen, click New Project. If you’ve already got any project open, choose File | New Project from the main menu.


2. Although you can create projects of various types in PyCharm, in this tutorial let's create a simple Pure Python project. This template will create an empty project.


pycharm

3. When you have created a new project or opened an existing one, it is time to start coding.

Create a Python file

pycharm

4. Select the option Python File from the context menu, and then type the new filename.

pycharm

PyCharm creates a new Python file and opens it for editing.


Python Indentation

Example

python
print("Hello World!") 
print('Hello World!')

Indentation refers to the spaces at the beginning of a code line.

Where in other programming languages the indentation in code is for readability only, the indentation in Python is very important.

Python uses indentation to indicate a block of code.

Example

python
if 5 > 2: 
    print("Five is greater than two!")

Output:

Five is greater than two!


Python will give you an error if you skip the indentation:


python
if 5 > 2: 
print("Five is greater than two!")

Output:

File "demo_indentation_test.py", line 2
print("Five is greater than two!")
^
IndentationError: expected an indented block


The number of spaces is up to you as a programmer, the most common use is four, but it has to be at least one.


python
if 5 > 2:
 print("Five is greater than two!")
if 5 > 2:
        print("Five is greater than two!")

Output:

Five is greater than two!

Five is greater than two!