# Cheat Sheet

## Definitions / examples

{% embed url="<https://github.com/gto76/python-cheatsheet>" %}

{% embed url="<https://github.com/geekcomputers/Python>" %}

{% embed url="<https://github.com/vinta/awesome-python>" %}

## Install multiple versions

Install all packages.

```bash
apt update
apt install python2.7 python2.7-dev
apt install python3.5 python3.5-dev
apt install python3.6 python3.6-dev
```

Update alternatives for python (2).

```bash
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 2
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 3
sudo update-alternatives --config python
```

Select python2.7

Update alternatives for python3.

```bash
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2
sudo update-alternatives --config python3
```

Select python3.6

Fix pip.

```bash
sudo pip install pip --upgrade
sudo python3 -m pip uninstall pip
sudo apt install python3-pip --reinstall
wget https://bootstrap.pypa.io/get-pip.py
sudo python3.6 get-pip.py
```

## Import module from parent dir

```bash
script_path = os.path.dirname(os.path.realpath(__file__))
root_path = f"{script_path}/../../../"
sys.path.insert(0, root_path)
from mymodule import myfile
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.devops.buzz/public/python/cheat-sheet.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
