import os.path error
import os.path error
Can you please inform me if the os.path module has been implemented in pybv10-2016-06-18-v1.8.1-65-gcbbd0a.dfu as when I import os.path I receive "ImportError: no module named 'os'.
Re: import os.path error
os.path is not implemented in MicroPython. The module uos contains a sobset of Python's module os. On Pyboard, os is the alias of uos. For Linux MicroPython there exists a micropython-lib (https://github.com/micropython/micropython-lib) with a lot of extensions, including os.path. But that's not portable to PyBoard.
Re: import os.path error
Many thanks for the prompt response...
Re: import os.path error
@66229: Update - a closer look into micropython-lib showed, that there is a os.path implementation, which should be easily portable to Pyboard. It look that only o.path.exists() and os.path.isdir() would have to be adapted, and expanduser() is hardly applicable, but could also modified to return a reasonable value. But that should be possible using the os.stat() call. If you need specific methods, like split(), dirname() or basename(), you can take them from there.
- smazcontrol
- Posts: 1
- Joined: Sun Jul 09, 2017 1:20 pm
Re: import os.path error
I do not see possibility in MicroPython to check it simple like os.path.isfile
then use this code to solve in alternative way
len([item for item in os.listdir() if fname==item])>0
ref. [url]https://forum.pycom.io/topic/196/simple-file-checking[/url]
then use this code to solve in alternative way
len([item for item in os.listdir() if fname==item])>0
ref. [url]https://forum.pycom.io/topic/196/simple-file-checking[/url]
Re: import os.path error
Wouldn't it be better to just do:Code: Select all
len([item for item in os.listdir() if fname==item])>0
Code: Select all
fname in os.listdir()