#3804: Naming conventions for imports in GRASS codebase
-------------------------+-------------------------
Reporter: pmav99 | Owner: grass-dev@…
Type: defect | Status: new
Priority: normal | Milestone:
Component: Python | Version: svn-trunk
Keywords: | CPU: Unspecified
Platform: Unspecified |
-------------------------+-------------------------
There is a great deal of variation in the way that grass code does
imports. Just a few examples:
{{{
import grass.script as core
import grass.script as gcore
import grass.script as grass
import grass.script as gs
import grass.script as gscript
import grass.script as sgrass
import grass.script.core as core
import grass.script.core as gcore
import grass.script.core as grass
import grass.script.core as gscore
import grass.script.raster as grast
import grass.script.raster as raster
import grass.pygrass.utils as gutils
import grass.pygrass.utils as utils
import grass.lib.gis as gislib
import grass.lib.gis as libgis
}}}
I think it would be a good idea if a certain style was picked and
consistently used throughout the codebase.
#3804: Naming conventions for imports in GRASS codebase
--------------------------+-------------------------
Reporter: pmav99 | Owner: grass-dev@…
Type: defect | Status: new
Priority: normal | Milestone:
Component: Python | Version: svn-trunk
Resolution: | Keywords:
CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------
Comment (by sbl):
Sounds very reasonable to me and should also apply to addons.
That might make it a bit easier for new addon-devs.
A way to import, that can be applied at all levels while avoiding
potential conflicts with other libraries would be to add a g before the
names of the imported components, as it has been practice in many cases:
import grass.script as gscript\\
import grass.script.core as gcore\\
import grass.pygrass.utils as gutils
#3804: Naming conventions for imports in GRASS codebase
--------------------------+-------------------------
Reporter: pmav99 | Owner: grass-dev@…
Type: defect | Status: new
Priority: normal | Milestone:
Component: Python | Version: svn-trunk
Resolution: | Keywords:
CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------
Comment (by pmav99):
TBH, apart from:
{{{
import grass.script as grass
import grass.script.core as grass
}}}
which I seriously dislike, I don't have any strong opinions on the matter.
I agree though that @sbl's suggestion is probably the most reasonable
approach.