avatar Bite 236. User experience matters! Suggest matching files

We love it when CLI or web apps take the extra mile to be more user friendly. In this Bite you will tweak the user experience of a function yourself.

Have you noticed how Django's migrate.py helps you type in the right command?

$ python manage.py migrat
Unknown command: 'migrat'. Did you mean migrate?
Type 'manage.py help' for usage.

Using Python's difflib this is actually not that hard to implement. Let's roll our own using another theme: file matching.

Complete the get_matching_files function below. It takes a target directory Path object and filter_str str to match (case insensitive). If any files match exactly, return a list with matches. If there is no exact match, see if there are closely matching files and return those. If no closely matching files either, return an empty list.

Good luck and keep calm and code more Python!

Login and get coding
go back Intermediate level
Bitecoin 3X

61 out of 61 users completed this Bite.
Will you be Pythonista #62 to crack this Bite?
Resolution time: ~50 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 4.17 on a 1-10 difficulty scale.
» Up for a challenge? 💪

We use Python 3.8