uos vs os
Posted: Thu Aug 09, 2018 7:35 pm
I am still uncertain after reading official doc on the uos vs os (or u-anything vs anything). Can someone give me a quick explanation?
http://docs.micropython.org/en/latest/e ... index.html
Anyway, trying to use uos instead of os in my MicroPython code but I still want to share as much code as I can with a regular Python script that runs on a PC. What I did was I defined functions to hide the differences, such as how to start a serial port on ESP32 is different than a USB-serial port on a PC. No problem. Just define start_port() differently so the main code is the same on ESP32 and PC.
So when it comes to importing u modules, I thought, why not "import uos as os" so the code that is shared between ESP32 and PC only uses os.listdir() but different import commands? Since I am not very experienced with Python, I wonder if this practice has some negative side effects I don't yet know. I can still import os as a different name but when do I have to import os instead of relying on uos?
Thanks in advance!
http://docs.micropython.org/en/latest/e ... index.html
Anyway, trying to use uos instead of os in my MicroPython code but I still want to share as much code as I can with a regular Python script that runs on a PC. What I did was I defined functions to hide the differences, such as how to start a serial port on ESP32 is different than a USB-serial port on a PC. No problem. Just define start_port() differently so the main code is the same on ESP32 and PC.
So when it comes to importing u modules, I thought, why not "import uos as os" so the code that is shared between ESP32 and PC only uses os.listdir() but different import commands? Since I am not very experienced with Python, I wonder if this practice has some negative side effects I don't yet know. I can still import os as a different name but when do I have to import os instead of relying on uos?
Thanks in advance!