[Microbit-Python] importing modules using uflash

Radomir Dopieralski microbit at sheep.art.pl
Sun Sep 11 08:00:29 EDT 2016


Not quite.

It doesn't matter how you upload your main script -- you can use uFlash
or Mu or the online editor, or even prepare the hex file yourself by
hand. The thing is, that the hex file can contain only one python file
in it.

However, there is also internal filesystem on the micro:bit, where you
can put additional files to be imported by your main script. The most
convenient way to access that filesystem and upload your files is by
using the latest version of the Mu editor. Of course, you could as well
just write a program that creates the file and writes its contents, but
that is a little roundabout way of doing it.

I hope this helps.


On Sun, 11 Sep 2016 12:47:20 +0100
"hot.toast via Microbit" <microbit at python.org> wrote:

> So as i understand it,
> 
> 1. uFlash is limited to python scripts that contain all the local 
> function and class definitions. The only imports that are allowed are 
> those from the microbit version of micropython.
> 
> 2. If I want to import  "mymodule.py" from a file on my local hard 
> drive, I will have to use the latest version of the mu editor...
> 
> On 11/09/16 12:19, David Whale wrote:
> > Make sure you use the most up to date version of Mu though to do
> > this, as it was a feature that was added reasonably recently. The
> > version of Mu in the Raspberry Pi repo's is still out of date at
> > the moment, and might not have this feature included yet.


-- 
Radomir Dopieralski

-- 
Radomir Dopieralski


More information about the Microbit mailing list