docs: add 0.22 migration article

This commit is contained in:
Oleg Kalachev
2020-10-20 11:19:23 +03:00
parent 10076e35f4
commit 6b831359dc
4 changed files with 100 additions and 0 deletions

View File

@@ -84,6 +84,7 @@
* [LED strip (legacy)](leds_old.md)
* [Contribution Guidelines](contributing.md)
* [Migration to v0.20](migrate20.md)
* [Migration to v0.22](migrate22.md)
* [Clover-based projects](projects.md)
* [Drone show](clever-show.md)
* [Innopolis Open 2020 (L22_ÆRO)](innopolis_open_L22_AERO.md)

49
docs/en/migrate22.md Normal file
View File

@@ -0,0 +1,49 @@
# Migration to version 0.20
## Python 3 transition
Python 2 is deprecated since January 1st, 2020. The Clover platform moves to Python 3.
For running flight script instead of `python` command:
```bash
python flight.py
```
use `python3` command:
```bash
python3 flight.py
```
Python 3 has certain syntax differences in comparison with the old version. Instead of `print` *operator*:
```python
print 'Clover is the best'
```
use `print` *function*:
```python
print('Clover is the best')
```
The division operator operates floating points by default (instead of integer). Python 2:
```python
>>> 10 / 4
2
```
Python 3:
```python
>>> 10 / 4
2.5
```
For strings `unicode` type is used by default (instead of `str` type).
Encoding specification (`# coding: utf8`) is not necessary any more.
More details on all the language changes see in [appropriate article](https://sebastianraschka.com/Articles/2014_python_2_3_key_diff.html).

View File

@@ -90,6 +90,7 @@
* [Светодиодная лента (legacy)](leds_old.md)
* [Вклад в Клевер](contributing.md)
* [Переход на версию 0.20](migrate20.md)
* [Переход на версию 0.22](migrate22.md)
* [Мероприятия](events.md)
* [CopterHack-2021](copterhack2021.md)
* [CopterHack-2019](copterhack2019.md)

49
docs/ru/migrate22.md Normal file
View File

@@ -0,0 +1,49 @@
# Переход на версию 0.22
## Переход на Python 3
Python 2 был признан [устаревшим](https://www.python.org/doc/sunset-python-2/), начиная с 1 января 2020 года. Платформа Клевера переходит на использование Python 3.
Для запуска полетных скриптов вместо команды `python`:
```bash
python flight.py
```
теперь следует использовать команду `python3`:
```bash
python3 flight.py
```
Синтаксис языка Python 3 имеет определенные изменения по сравнения со второй версией. Вместо *оператора* `print`:
```python
print 'Clover is the best'
```
теперь используется *функция* `print`:
```python
print('Clover is the best')
```
Оператор деления по умолчанию выполняет деление с плавающей точкой (вместо целочисленного). Python 2:
```python
>>> 10 / 4
2
```
Python 3:
```python
>>> 10 / 4
2.5
```
Для строк по умолчанию теперь используется тип `unicode` (вместо типа `str`).
Указание кодировки файла (`# coding: utf8`) перестало быть необходимым.
Полное описание всех изменений языка смотрите в [соответствующей статье](https://pythonworld.ru/osnovy/python2-vs-python3-razlichiya-sintaksisa.html).