Welcome to the new platform of Programmers Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use it's exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
list files in a directory
hi, i just started with python. i want to get a list of files in a directory but i only want to see the latest files. i need this so that i can see what's the latest file i have based on their number.
for example, i have 3 files: file-1.txt,file-2.txt and file-3.txt
how do i make it so that only file-3.txt is shown?
i found that i could use dircache.listdir(path) but that just lists the files. hope my question is not too confusing.