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 [2016/12/29 16:29] – francois | python [2019/09/10 14:52] (Version actuelle) – francois | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | ==== Development Environment and librairies ==== | + | ====== Development Environment and librairies ====== |
+ | ===== Eclipse ===== | ||
+ | * pydev | ||
+ | * mylin | ||
- | Please here after the typical list of addition apckage I'm using. | + | ===== Modules ===== |
- | === pip compliant | + | |
- | * using pip : //py2exe//, pyqt5 , **pylint**, doxypypy, openpyxl , __rtcclient (optional)__ | + | Please here after the typical list of addition packages I' |
+ | Most of same are compliant with **pip** download installation mode:\\ | ||
+ | '' | ||
- | === other installtion mode ==== | + | * doxypypy : required for documentation generation |
- | == lxml == | + | * **pylint**: required for code quality |
- | As on Windows pip lxml installation failed, download the package from [[http:// | + | * openxl |
+ | * pyqt5 : | ||
+ | * __py2exe__ | ||
+ | * __rtcclient__ : optional RTC management | ||
+ | * lxml (see below for installation) | ||
+ | * pywin32 (see below fo installation) | ||
+ | * unidecode (pylib) | ||
- | '' | + | === lxml installation instructions === |
+ | As on Windows download pip lxml installation may failed, use the file pip installation mode: | ||
+ | * download the package from [[http:// | ||
+ | * '' | ||
- | == pywin32 == | + | === pywin32 |
- | * use '' | + | Three install solutions are availble: |
- | * donwload | + | |
- | ==== Fundamental Rules ==== | + | - download |
+ | - Install form source package | ||
+ | | ||
+ | = installation issue workaround | ||
+ | If the install package complains to not find any Python36 amd64 installation, | ||
- | == RUL_GEN_001 Comments | + | = installation from source package |
- | A comment | + | * Download the source package, unzip it |
- | Comment shall not contradict | + | * Make sure to have latest visual studio SDK installed |
+ | * Open SDK command line (https:// | ||
+ | * Choose Start, expand All Programs, Visual Studio, Visual Studio Tools, and then choose a command prompt | ||
+ | * Make sure your python installation is in PATH \\ '' | ||
+ | * Run the following command from source directory: | ||
+ | * If your experimented the following issue\\ | ||
+ | |||
+ | > python setup3.pl install | ||
+ | Converting... | ||
+ | Executing... | ||
+ | Building pywin32 3.6.220.0 | ||
+ | Traceback (most recent call last): | ||
+ | File " | ||
+ | exec(str(got)) | ||
+ | File "< | ||
+ | File "< | ||
+ | File " | ||
+ | path = os.fspath(path) | ||
+ | | ||
+ | |||
+ | |||
+ | Setup.py is looking for Visual Studio SDK and is not able to find it (I got this with Visual Studio 15), to workaorinf this you have to manually set the MsSdk environment variable. | ||
+ | * Search for windows.h in c:\Program Files (x86)\Microsoft SDKs | ||
+ | * '' | ||
+ | * Run ' | ||
+ | |||
+ | * For a full installation process inclusing COM components do to same configuration and commands from a Command line opened 'as Adminstrator' | ||
+ | |||
+ | SET PYTHONDIR=C: | ||
+ | SET PATH=%PYTHONDIR%; | ||
+ | # CD %PYTHONDIR%\pywin32-220 | ||
+ | # SET MSSdk=c: | ||
+ | # python setup3.py -q build | ||
+ | # python setup3.py -q install | ||
+ | |||
+ | ====== Development Rules ====== | ||
+ | |||
+ | ===== Fundamental Rules ===== | ||
- | == RUL_GEN_002 | + | == RUL_GEN_001 |
<note tip> | <note tip> | ||
If you don't understand why you should not modify a line, **DON' | If you don't understand why you should not modify a line, **DON' | ||
</ | </ | ||
- | == RUL_GEN_003 | + | |
+ | == RUL_GEN_002 | ||
Don't modify a line just to make it nicer, better, what ever justification you want, until there is a declared issue or an enhancement or task assigned to you linked with the line. | Don't modify a line just to make it nicer, better, what ever justification you want, until there is a declared issue or an enhancement or task assigned to you linked with the line. | ||
- | == RUL_GEN_004 | + | == RUL_GEN_004 |
<note warning> | <note warning> | ||
**In any case, Keep it simple** | **In any case, Keep it simple** | ||
</ | </ | ||
- | ===== Coding Rules ===== | + | == RUL_GEN_005 Guru rule== |
- | == RUL_COD_001 == | + | Do what I say, Don't do what I do. |
+ | |||
+ | ===== Comment Rules ===== | ||
+ | |||
+ | == RUL_CMT_001 Comments == | ||
+ | A comment is there to explain the code not to rephrase it.\\ | ||
+ | Comment shall not contradict the code, update the comment with the code. | ||
+ | |||
+ | == RUL_CMT_002 Doc Strings == | ||
+ | Always use DocStrings for Files, Class and functions comment block.\\ | ||
+ | |||
+ | == RUL_CMT_004 DocString is for users == | ||
+ | DocString section is for user of the element not for developper/ | ||
+ | |||
+ | == RUL_CMT_003 Maintainer comments == | ||
+ | Use standard comment immediatly of SocString section for developper/ | ||
+ | |||
+ | ===== Coding Rules ===== | ||
+ | == RUL_COD_001 | ||
+ | Python 3.7 is the preferred Python version. If Python2 is required use Python 2.7.< | ||
+ | |||
+ | |||
+ | == RUL_COD_002 | ||
Follow the Python development guidelines described in [[https:// | Follow the Python development guidelines described in [[https:// | ||
- | ==== Edition Rule ==== | + | == RUL_COD_003 |
+ | Use Pylint to check to compliance of your code **AND FIX ALL WARNINGS**.\\ Justification is required when you disable a checker. | ||
- | == ADV_GEN_005 Tab is not space== | ||
- | Configure your editor to replace tab by 4 spaces (4). If your editor is not enable to replace don't insert TAB. | ||
- | == RUL_GEN_006 Indentation == | ||
- | Always use 4 space indentation except for arguments indentation | ||
+ | ==== Edition Rule ==== | ||
+ | |||
+ | == RUL_WRI_001 Tab is not space== | ||
+ | Configure your editor to replace TAB character by **4 spaces**. If your editor is not enable to replace automatically, | ||
+ | |||
+ | == RUL_WRI_002 : UTF-8 (deprecated as default in Python3) == | ||
+ | Make sure your environment is configured to use only ' | ||
+ | # -- coding: | ||
+ | |||
+ | == RUL_WRI_003 : Activate future features (Python2 only) == | ||
+ | |||
+ | Make your Python2 code compliant with Python3 by inserting at least : (from [[https:// | ||
+ | |||
+ | from __future__ import absolute_import | ||
+ | from __future__ import division | ||
+ | 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 == | ||
+ | Always use **4 spaces** indentation except for function arguments indentation.(see PEP008) | ||
+ | |||
+ | ==== Strings ==== | ||
+ | |||
+ | == RUL_STR_01 bytes storage (was: str usage) == | ||
+ | Python2: Use '' | ||
+ | Python3: Use only '' | ||
- | === Strings === | ||
- | == RUL_STR_01 str usage == | ||
- | Use '' | ||
== 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.1483028957.txt.gz · Dernière modification : 2016/12/29 16:29 de francois