Changes

From Gramps

Programming guidelines

1,333 bytes added, 12 May
Imports: Sections grouping and headers
{{man note|Important:|files in the gen submodule are '''not''' allowed to import files from the other submodules. So <code>gen</code> should be self-contained.}}
 
Generally (i.e. this is guidance, not a inviolable rule) imports should be grouped into three main sections: Python, GTK etc. and Gramps. Not all sections are required, include only those that apply. Other sections, or further grouping can be used if the developer thinks this will be useful. It may be useful to put imports in alphabetical order, but a logical order is also acceptable and may be preferable in some cases. It will often be useful to precede each main section with comment headers as in the following example:
 
<pre>
# -------------------------------------------------------------------------
#
# Standard Python modules
#
# -------------------------------------------------------------------------
import os
import logging
 
# -------------------------------------------------------------------------
#
# GTK/Gnome modules
#
# -------------------------------------------------------------------------
from gi.repository import Gtk
 
# -------------------------------------------------------------------------
#
# Gramps modules
#
# -------------------------------------------------------------------------
from gramps.gen.db.base import DbReadBase
from .mymodule import MyClass
</pre>
 
Where existing code has not followed this guidance, it will not normally be necessary to change the code to follow this guidance.
== Class headers ==
manual
405
edits

Navigation menu