python
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| python [2019/08/09 16:50] – [Fundamental Rules] francois | python [2019/09/10 14:52] (Version actuelle) – francois | ||
|---|---|---|---|
| Ligne 88: | Ligne 88: | ||
| **In any case, Keep it simple** | **In any case, Keep it simple** | ||
| </ | </ | ||
| + | |||
| + | == RUL_GEN_005 Guru rule== | ||
| + | |||
| + | Do what I say, Don't do what I do. | ||
| ===== Comment Rules ===== | ===== Comment Rules ===== | ||
| Ligne 106: | Ligne 110: | ||
| ===== Coding Rules ===== | ===== Coding Rules ===== | ||
| == RUL_COD_001 : Python version == | == RUL_COD_001 : Python version == | ||
| - | Python 3.6 is the preferred Python version. If Python2 is required use Python 2.7.< | + | Python 3.7 is the preferred Python version. If Python2 is required use Python 2.7.< |
| Ligne 127: | Ligne 131: | ||
| == RUL_WRI_003 : Activate future features (Python2 only) == | == RUL_WRI_003 : Activate future features (Python2 only) == | ||
| - | Make your Python2 code compliant with Python3 by inserting at least : | ||
| - | | + | Make your Python2 code compliant with Python3 by inserting at least : (from [[https:// |
| + | |||
| + | from __future__ import absolute_import | ||
| + | | ||
| from __future__ import print_function | from __future__ import print_function | ||
| + | from __future__ import unicode_literals | ||
| + | | ||
| + | from builtins import * | ||
| + | | ||
| + | from future import standard_library | ||
| + | standard_library.install_aliases() | ||
| + | |||
| | | ||
| == RUL_WRI_004 Indentation == | == RUL_WRI_004 Indentation == | ||
| Ligne 136: | Ligne 149: | ||
| ==== Strings ==== | ==== Strings ==== | ||
| + | |||
| == RUL_STR_01 bytes storage (was: str usage) == | == RUL_STR_01 bytes storage (was: str usage) == | ||
| Python2: Use '' | Python2: Use '' | ||
| Ligne 141: | Ligne 155: | ||
| == RUL_STR_002 QString usage == | == RUL_STR_002 QString usage == | ||
| + | |||
| Use '' | Use '' | ||
| == RUL_STR_003 Use unicode == | == RUL_STR_003 Use unicode == | ||
| + | |||
| For all other strings use '' | For all other strings use '' | ||
| === Classes === | === Classes === | ||
| + | == RUL_CLS_001 Forget old-style class == | ||
| + | |||
| + | Python 2: Any class MUST inherit directly or indirectly from ``object``. | ||
| + | |||
| + | == RUL_CLS_002 == | ||
| + | |||
| + | Use ``self`` to identify instance parameter and ``cls`` for class related parameter. | ||
| + | |||
| + | == RUL_CLS_003 == | ||
| + | |||
| + | |||
python.1565369413.txt.gz · Dernière modification : 2019/08/09 16:50 de francois