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

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

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

Post by pfalcon » Wed Dec 12, 2018 4:54 pm

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>
...
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

User avatar
pythoncoder
Posts: 3508
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

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

Post by pythoncoder » Thu Dec 13, 2018 9:43 am

Very useful :D
Peter Hinch

Post Reply