do Path-file objects have any method to delete itself if its a file? can we use os.remove? method .rmdir() can't be used when correspond to file?
            Asked
            
        
        
            Active
            
        
            Viewed 32 times
        
    0
            
            
        - 
                    https://stackoverflow.com/q/6996603/1531971 If there is some specific API you are referring to, what have you tried? – Apr 19 '18 at 16:59
1 Answers
1
            You can check if the path is file or directory with:
os.path.isfile("asd.txt")
os.path.isdir("asd")
And you can delete it with:
os.remove() will remove a file.
os.rmdir() will remove an empty directory.
shutil.rmtree() will delete a directory and all its contents.
 
    
    
        Benjámin Gerván
        
- 216
- 3
- 9
