[Microbit-Python] importing modules using uflash
M.-A. Lemburg
mal at egenix.com
Wed Sep 14 16:03:57 EDT 2016
On 14.09.2016 21:55, Radomir Dopieralski wrote:
> It just uses normal python commands, such as open(), file.read(),
> file.write(), os.listdir() and so on, but executes them over the REPL
> console. You can see exactly what it does here:
> https://github.com/ntoll/mu/blob/master/mu/contrib/microfs.py
Great, thanks.
I think this would make an excellent addition to the uflash
tool - for those of us who prefer emacs over mu ;-)
> On Wed, 14 Sep 2016 21:15:22 +0200
> "M.-A. Lemburg" <mal at egenix.com> wrote:
>
>> On 11.09.2016 14:00, Radomir Dopieralski wrote:
>>>
>>> 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.
>>
>> Is the functionality needed for uploading modules to the
>> MB documented somewhere ? (A pointer to the right place
>> in the Mu editor code would already help :-))
>>
>> Background: I've been looking for something like a few months
>> ago and back then, there was no filesystem module import for
>> the MB.
>>
>> Thanks.
>>
>>> 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.
>>>
>>>
>>
>
>
>
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Experts (#1, Sep 14 2016)
>>> Python Projects, Coaching and Consulting ... http://www.egenix.com/
>>> Python Database Interfaces ... http://products.egenix.com/
>>> Plone/Zope Database Interfaces ... http://zope.egenix.com/
________________________________________________________________________
::: We implement business ideas - efficiently in both time and costs :::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
http://www.egenix.com/company/contact/
http://www.malemburg.com/
More information about the Microbit
mailing list