The Python in our MakeCode editor is different to the MicroPython in our Python editor. Although both editors appear like Python 3 they actually are completely different in the way their programs are interpreted and run. This explains why you may find programs which run fine in the MicroPython editor cause bugs in our MakeCode editor, or vice versa. For example, our simple “Hello, World” program in MakeCode Python would appear as:
Where as in MicroPython you would have to import modules first, and then call different classes as follows:
from microbit import *
The difference in syntax shows us how the two languages have differing APIs.
MakeCode Python runs the micro:bit DAL (Data Abstraction Layer) just as the other languages in MakeCode do. It is in fact just static TypeScript surfaced with Python syntax. This is the same structure as the blocks in the MakeCode editor, which is why it is possible to switch between the different languages. However, this does mean that there are certain limitations to MakeCode Python, as it shares the same limitations as the other languages in MakeCode. One example of this would be the limitation to access of only 3 PWM pins on the micro:bit. You can access the MakeCode Python API in the documentation https://makecode.microbit.org/reference. This shows how the different functions map on to each other across languages.
MicroPython is different to this, as this has its own runtime on the micro:bit. MicroPython is in fact a tiny python interpreter that runs on the board (at a low level) and is a popular programming language because it is optimised to work on microcontrollers — just like the micro:bit. It is almost a full re-implementation of python 3 but is designed to be able to run in a low memory and low power environment. The python editor provided by micro:bit is the perfect environment for building programs to run on your micro:bit, as you can easily access the REPL (Read, Evaluate, Print, Loop) and also connect directly to your micro:bit to flash programs via serial connection. Furthermore, there is an easy to use file system where you can drag in modules you have created. You can access the MicroPython API documentation here https://microbit-micropython.readthedocs.io/en/latest/.