Hi developers,

While writing a python script in the QGIS python console editor I needed to write a new class and for convenience I put that in its own python file.

Both files are in the same directory, but I cannot import my class in the other script.

Here's an example:


# script_1.py

from .script_2 import TestClass
obj1 = TestClass('Ray')
print(obj1)




# script_2.py:

class TestClass():

    def __init__(self, name):
        self.name = name

    def __str__(self):
        return f'TestClass[{self.name}]'



It all works properly if I put my class definition in script_1 but as the code is growing (and a customer of mine needs to understand this too) it would really be nice to split the code over multiple files.
Is there a way? Or another approach?

Kind regards,
Raymond
_______________________________________________
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to