[QGIS-Developer] Converting plugins to QGIS 3

Raymond Nijssen r.nijssen at terglobo.nl
Wed May 10 12:11:58 PDT 2017


Hi Calvin,

Here are some thoughts on python imports:

https://www.python.org/dev/peps/pep-0008/#imports

The last paragraph is about using wildcards.

Raymond

On 10-05-17 20:03, C Hamilton wrote:
> I am wondering how important it is to import the modules separately.
> Such as:
>
> from qgis.core import QGis, QgsCoordinateTransform, QgsRectangle,
> QgsPoint, QgsGeometry
>
> Does it really make a difference? I am finding that you have to make
> sure every part of your code is exercised so that nothing was missed. By
> doing the above there is more of a chance to have a bug. Perhaps for
> PyQt4.QtGui it makes sense, but there is less chance to have a python
> error if you keep.
>
> from qgis.core import *
> from PyQt4.QtGui import *
> from qgis.gui import *
>
> Thoughts?
>
> Thanks,
>
> Calvin
>
>
>
> On Wed, May 10, 2017 at 12:00 PM, Luigi Pirelli <luipir at gmail.com
> <mailto:luipir at gmail.com>> wrote:
>
>     this is a slide about plugin porting I'll be presenting to the next
>     spanish foss4g:
>     http://slides.com/luigipirelli/desdarrolloplugindeqgis-xi-girona#/17
>     <http://slides.com/luigipirelli/desdarrolloplugindeqgis-xi-girona#/17>
>     sorry it's in spanish
>
>     about
>
>     from PyQt4 import QtGui
>
>     or
>
>     from PyQt4.QtGui import QDialog
>
>     I would prefer the second so to avoid to postpone lib version errors
>     at pyc time and not at runtime.
>     it make it simpler to mock or alias a class globally if you need
>
>     regards
>     Luigi Pirelli
>
>     **************************************************************************************************
>     * Boundless QGIS Support/Development: lpirelli AT boundlessgeo DOT com
>     * LinkedIn: https://www.linkedin.com/in/luigipirelli
>     <https://www.linkedin.com/in/luigipirelli>
>     * Stackexchange:
>     http://gis.stackexchange.com/users/19667/luigi-pirelli
>     <http://gis.stackexchange.com/users/19667/luigi-pirelli>
>     * GitHub: https://github.com/luipir
>     * Mastering QGIS 2nd Edition:
>     *
>     https://www.packtpub.com/big-data-and-business-intelligence/mastering-qgis-second-edition
>     <https://www.packtpub.com/big-data-and-business-intelligence/mastering-qgis-second-edition>
>     **************************************************************************************************
>
>
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>



More information about the QGIS-Developer mailing list