Python Snippets

Sunday, March 24 2024

I always find myself writing these snippets over and over again. Maybe they already exist in some libraries I haven't discovered yet?


def make_path(*filepaths):
    return os.path.join(os.path.abspath(os.path.dirname(__file__)), *filepaths)
def get_random_float(N, M):
    assert N <= M
    return round(random.uniform(N, M), 2)


I'll add more here as time goes on, and I work on my projects. Feel free to share yours too, and I can include them in this post!

No comments yet...