Page 1 of 1

"site" module for MicroPython, with help() command

Posted: Wed Dec 12, 2018 4:54 pm
by pfalcon
Users of Unix port of MicroPython know that it doesn't contain builtin help() command. The reason for that is MicroPython philosophy, which says: "Anything which can be implemented in Python, should be implemented in Python" (more details: https://github.com/micropython/micropyt ... Guidelines).

Well, over this time, such an implementation didn't (widely) surfaced, so I finally went to add an of "site" module with implementation of that command. "site" is the module which is automatically loaded by CPython on start. Unfortunately, there's incompatibility in MicroPython - instead of "site" it loads "boot" instead. This incompatibility was reported long ago, but went unresolved: https://github.com/micropython/micropython/issues/1741 . All in all, "site" needs to be imported manually, though I consider fixing that.

https://pypi.org/project/micropython-site/

Code: Select all

$  micropython -m upip install micropython-site
$  micropython
>>> import site
Type "help()" for more information.
>>> help("foo")
object foo is of type str
  center -- <function>
  count -- <function>
  encode -- <function>
  endswith -- <function>
  find -- <function>
  format -- <function>
  index -- <function>
  isalpha -- <function>
  isdigit -- <function>
  islower -- <function>
...

Re: "site" module for MicroPython, with help() command

Posted: Thu Dec 13, 2018 9:43 am
by pythoncoder
Very useful :D