The Python in the MakeCode editor is different to the MicroPython in the micro:bit 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 that run fine in the MicroPython editor cause bugs in the MakeCode editor, or vice versa.  For example, our simple “Hello, World” program in MakeCode Python would appear as:


basic.show_string("Hello!")

basic.show_icon(IconNames.HEART)


Where as in MicroPython you would have to import modules first, and then call different classes as follows:


from microbit import *


while True:

    display.scroll('Hello, World!')

    display.show(Image.HEART)

    sleep(2000)



The difference in syntax shows us how the two languages have differing APIs. 


MakeCode Python

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

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/.


Each editor has its benefits;  MakeCode Python provides scope to convert code from blocks or javascript to python, or the other way around and the Python Editor provides MicroPython which is much more similar to Python 3 and so people can learn the popular language which is widely used across many editors and boards.

The Micro:bit Educational Foundation are really committed to ongoing support of MicroPython on the BBC micro:bit; both for the online Python Editor at python.microbit.org and to help support the amazing diversity of community editors for the micro:bit that use MicroPython.