simple file checking



  • two questions about simplify things in micropython like it is in normal python

    1. How to check if file exists?
      i do not see possibility to check it simple like os.path.isfile
      maybe i do something wrong but i try "all" simple posibilities and finish in this crap of code:
    len([item for item in os.listdir() if fname==item])>0
    
    1. how to check file size?
      i tied this:
    os.stat(fname).st_size 
    

    but it do not understand st_size
    and now i write exact idx like:

    os.stat(fname)[6]

Log in to reply
 

Looks like your connection to Pycom Forum was lost, please wait while we try to reconnect.