frame

Importing a Class

Hi,

Is it not possible to import just a class from a module (file) with:
 from file import class
as it works normally in other python environments?
I tried but didn't work. Am I doing a mistake?

Comments

  • Hi ta1db,

    No, it is not possible; in Python, the imported module is always fully loaded and you can "rename" the classes inside the imported module to easy the usage but this procedure wastes resources (creating a "copy" of the class) that in microcontrollers are the most important aspect to preserve in building applications.

    So in general, you can always use the "module.class" syntax to manage the internal class of an imported module; otherwise, you can follow, for example, the Bignum sample code where bg is used instead of bignum module.

    Hope this can help you
    Matteo Cipriani
    Zerynth Support Team
Sign In or Register to comment.

ZERYNTH Community

@ 2016 Zerynth.com, all rights reserved.