Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I am suspicious of names containing "and".

I agree about clarity over everything else, but then why even make a function if all it does is calling 2 functions in sequence, and you can't name it on higher level of abstraction?

In this case wouldn't

    [x+1 for x in input_list.reversed()]
be even clearer?

True, functions allow you to change code in one place and affect many places (so they prevent "forgot to update one place" errors), but when function is named from its implementation instead of its purpose - it doesn't make much sense to change implementation anyway. The absolute worst thing is

    def reverseListAndAddOneToEachElement(input_list):
        #requirements changed
        return [x+2 for x in input_list.reversed()]
So either I repeat myself by copy-pasting code, or I repeat myself by saying the same thing in implementation and in the name. It's the hardest problem in naming for me.


Function composition is by far the better solution, it is future proof and requires less memorization.


It's syntax is just somewhat ugly in Python. (Compared to, say, Haskell.)


> but then why even make a function if all it does is calling 2 functions in sequence

How else would you execute the functions? What initiates them?


The "and you can't name it on higher level of abstraction" part is important.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: