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

IIRC, pep8 would have you write:

    def my_very_very_very_very_very_long_function_name(self,
                                                       param1,
                                                       param2):


Looking at it (https://www.python.org/dev/peps/pep-0008/), that is one of the options, but you could also do:

  def my_very_very_very_very_very_long_function_name(
          self, param1, 
          param2):
      pass
Shrug. Seems okay to me, and preferable to what they say no to.


You can choose to use:

    def my_very_very_very_very_very_long_function_name(
            self, param1, param2):
        ...


Ah, my mistake.


My preference is to do this, which I think is quite nice and easy to work with:

    def my_very_very_very_very_very_long_function_name(
            self,
            param1,
            param2,
            ):
        do_it()  # function body here.


Yup this. It works perhaps even more nicely in languages that have braces and return types, e.g.

    func some_name(
        arg: Type,
        arg2: Type
    ) -> RetVal {
        …
    }


Yep, this is by far my least favorite autopep8 "correction".


if your function name is that long, you have a problem




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

Search: