Replies: 6 comments 1 reply
-
What is the motivation for this?
You can modify the modos.c file if you need to implement something in C or os in micropython-lib if it can be implemented in Python. |
Beta Was this translation helpful? Give feedback.
-
As @dlech points out, these functions can be implemented also in Python. For example a search for "os.walk source code" brings up some results, including the source of CPython. These results will have to be adapted to Micropython. |
Beta Was this translation helpful? Give feedback.
-
@dlech @bixb922 Thank you for your responses! I do not want to add the entire os module, but I definitely would like other common attributes such as walk and other unique ones for complex problems. Now, I think the next step is to figure out how to adapt this code for MicroPython. If anyone could help me create an example folder/file to add the os.walk functionality that would be helpful. Either way, I look forward to spending the next couple of days understanding the MP syntax. |
Beta Was this translation helpful? Give feedback.
-
The unix-ffi package in micropython-lib has a bunch of stuff implemented already: https://github.com/micropython/micropython-lib/blob/master/unix-ffi/os/os/__init__.py |
Beta Was this translation helpful? Give feedback.
-
@Qdog31 As already pointed out we provide an example of extending the For more documentation on extending built-in modules from Python see this recently updated documentation: https://docs.micropython.org/en/latest/library/index.html#extending-built-in-libraries-from-python |
Beta Was this translation helpful? Give feedback.
-
@dlech I'm currently looking at the file you shared, and it has a walk definition. However when I build the unix port, there still is not a walk attribute. How can I add this?
I currently placed this file in all directories having to deal with lib, because I am not sure where it goes. Does it go within /lib/micropython-lib or /lib/micropython-lib/python-stdlib, etc? Lastly, would it be easier to add modules this way or to freeze them? I am still looking into the differences. |
Beta Was this translation helpful? Give feedback.
-
Hello, I have been working with MP for a couple of weeks now and was wondering if someone could help me with figuring out how to add the remaining attributes to the os module within MP?
I currently have a compiled unix port executable and am attempting to utilize the entirety of the python os module within the MP REPL. However, I only have the following attributes:
My question: When running the same command (dir(os)) with python3, it seems like there are well over a hundred. How can I add the rest of these attributes? If this is not possible, I am interested in learning how to atleast manually add ones that I choose. For example, the os.walk() method would be useful to have.
I have been messing around with the usercmodule example, but am super confused on how I could modify these files with the os module code.
Beta Was this translation helpful? Give feedback.
All reactions