import default ?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
prem111
Posts: 111
Joined: Sun Feb 23, 2020 3:18 pm

import default ?

Post by prem111 » Sat Feb 20, 2021 11:46 am

When I have frozen code in firmware, in main.py file on / flash I will do an import, import from frozen code, how to "force" to load from / first, and when it is not there with firmware? Thanks.

User avatar
Roberthh
Posts: 2454
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: import default ?

Post by Roberthh » Sat Feb 20, 2021 4:25 pm

The load order is defined in sys.path, with to he empty string standing for frozen code.
You cannot directly assign to sys.path, so you have to call sys.path.pop(0) to remove the first item, and append to add one.

prem111
Posts: 111
Joined: Sun Feb 23, 2020 3:18 pm

Re: import default ?

Post by prem111 » Sun Feb 21, 2021 11:01 am

Everything is clear, thank you for your answer and help!

Post Reply