To return a value or not return a value
I believe any function that changes a variable should return a variable. For example, I argue that Python's random.shuffle() is flawed. This is how random.shuffle() unfortunately works: import rand...

Source: https://daniel.feldroy.com
I believe any function that changes a variable should return a variable. For example, I argue that Python's random.shuffle() is flawed. This is how random.shuffle() unfortunately works: import random my_list = [1, 2, 3, 4, 5] print(f"Original list: {my_list}") # Change happens in place # my_list is forever changed random.shuffle(my_list) print(f"Shuffled list: {my_list}") In my opinion, random.shuffle() should work like this: import random my_list = [1, 2, 3, 4, 5] # Function returns a new, shuffled list new_list = random.shuffle(my_list) print(f"Original list: {my_list}") print(f"Shuffled list: {new_list}") Of course, Python won't fix this mistake to fit my preference. There's too many places in the universe expecting random.shuffle to change a list in place. Yet it still bugs me every time I see the function. Stuff like this is why I created my listo package, it allowed me to get past my own sense of annoyance. The listo library is barely used,