How to avoid overwriting files in python

Strategy 1: increment a suffix so like “file.pdf(1)” Version: Simple Version: Guards against race conditions The above is safe if there is only one process writing to the location but it can include a race condition. This is the safer version that “opens” the file. Strategy 2: attach a timestamp

How to use the python rank-bm25 library

Note: this library is called rank-bm25 on pypi (pypi) and NOT bm25 Official docs (github) say: However, you often want to clean the corpus (lowercase, remove punctuation) before indexing the corpus. Once you do that you must keep the original corpus around that index into the original unedited strings. This works for most cases! Note,…

Use pyenv and a .python-version file

Problem: Have you ever downloaded someones project and ran into python versioning issues? Solution: You need to pin the python version for every project How? pyenv will recognize a .python-version file and use the python version that you pinned for your project, directory or system. This is massively useful when working across different machines and…