Python is high-level interpreted, programming language. It supports procedural, object-oriented and functional programming paradigms.

Python is dynamically typed, although since 3.5 it added a module to support type hints. Linters such as Ruff, Flake8, isort or Black.

Python much like Node.js, has it's own package manager, pip, and it's alternatives, the industry standard being Poetry, and the newcomer being uv

Voucher for the certification

Use Cases

Web Dev

Data Sci & Machine Learning

Scientific Computing

Gamedev

Syntax

   def greet(name):
       return f"Hello, {name}!"
fruits = ["apple", "banana", "cherry"]  # List - mutable, ordered
person = {"name": "Alice", "age": 30}   # Dictionary - mutable, key-value pairs
coordinates = (10, 20)                  # Tuple - immutable, ordered

#atom
A virtual environment (venv) is a way for Python to separates the packages and dependencies from a project from the system-wide setup.

Creating a venv

A virtual env is created by the command python -m venv <name>

And it creates a file structure such as:

venv/
├── pyvenv.cfg
├── bin/ (or Scripts/ on Windows)
│   ├── activate
│   ├── activate.bat (Windows)
│   ├── python -> /usr/bin/python3.9
│   └── pip
├── include/
├── lib/
│   └── python3.9/
│       └── site-packages/
└── share/

Activating a venv

To activate it you should run the activate script;

# On Linux/Mac
source myproject/bin/activate

# On Windows Command Prompt
myproject\Scripts\activate.bat

# On Windows PowerShell
myproject\Scripts\Activate.ps1

When activated the shell prompt will change to display the venv name, the PATH will change to prioritize the python & pip in the bin folder.

Deactivating

Just run the command deactivate

It's recommended to not commit virtual envs, thus ignore them in .gitignore.

Poetry and uv have their own way of managing venvs, so refer to those pages.

History


Connections:


Sources:

#Python #Programming #SoftwareDevelopment #DataScience #Automation