Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More detailed info from help() #73

Closed
kisvegabor opened this issue Apr 6, 2020 · 2 comments
Closed

More detailed info from help() #73

kisvegabor opened this issue Apr 6, 2020 · 2 comments

Comments

@kisvegabor
Copy link
Member

Hi,

I remember that we have talked about improving help() to tell more info about functions but I don't remember if it was implemented or not. E.g. tell the type of the parameters and return value for help(lv.btn).

If implemented can you tell how it can be used?

@amirgon
Copy link
Collaborator

amirgon commented Apr 6, 2020

Extraction of information (meta-data) about a program is called Introspection or Reflection.
In Micropython, Introspection is only partially supported.

Since Micropython is designed for embedded devices with limited resources, it does not make sense to always keep full metadata about the program (such as parameter names, types etc.). That would consume precious memory (either RAM or Flash).

Some introspection is supported though. You can, for example, get a list of attributes of an object, or a list of functions in a module, because this is something Micropython has to maintain anyway, being a dynamic language. (see dir, which is supported in Micropython)

But you are right - we discussed this in another context: lvgl GUI builder.

lvgl/lv_gui_builder#1 (comment)

A Micropython GUI builder would need introspection so it could automatically display what are all the setters and getters of a widget, and call them with the right parameters (for example).
For that purpose I added an option to generate metadata (in the form of a JSON file) that contains information missing from Micropython's reflection.

@kisvegabor
Copy link
Member Author

Thank you very much!
The JSON file is perfect!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants