[Baypiggies] PEP-8 Style Interpretation Question

Matt Good matt at matt-good.net
Thu May 15 23:12:29 CEST 2008


On May 15, 2008, at 1:40 PM, Glen Jarvis wrote:

> The discussion revolves around code of this nature (obviously a  
> cooked example where it is not necessary to place each attribute of  
> demo on a new line. Comments omitted purposely):
>
> def demo(
>         first_attribute,
>         second_attribute
>         ):
>     print "spam"

If the first parameter can't fit in the 79 character limit then this  
would be ok, except the ): should go on the line with second_attribute  
instead of wrapping, e.g:

def demo(
         first_param,
         second_param):
     print 'spam'

> def demo(first_attribute,
>                   second_attribute):
>     print "spam"

Yes, PEP 8 explicitly prefers this style, though occasionally even the  
first parameter won't fit in the line length limit in which case you'd  
need to wrap it like above.

> I could compromise to
> def demo(
>     first_attribute,
>     second_attribute):
>
>     print "spam"

I prefer double-indenting as in the first example above since it keeps  
the parameters visually separated from the function body.

-- Matt


More information about the Baypiggies mailing list