[Twisted-Python] My pet peeve ugly coding style

Steve Waterbury golux at comcast.net
Thu Jul 10 18:27:10 MDT 2003


Glyph Lefkowitz wrote:
> On Thursday, July 10, 2003, at 02:17 PM, Tommi Virtanen wrote:
>>
>>     Yes, and that's part of the problem; not the reason
>>     why ugly code should be tolerated.
> 
> This is a highly subjective discussion, of course.  ...

... true ... and my gut votes with Tommi.

>   return foo (
>     ).addCallback(bar
>     ).addCallback(baz
>     ) # ...

IMHO, that's still ugly.

> If the proper placement of parentheses is a particular problem for you, 
> consider
> 
>   return (foo()
>           .addCallback(bar)
>           .addCallback(baz)
>           .addCallback(boz))
> 
> which is a style that I often prefer.

Somewhat better, but I still like Tommi's example.

> If you think _that_ is too ugly, then I wonder how you would wrap 
> parameters across multiple lines  ...

To me, that's a separate issue.

> As in any coding style discussion, consistency wins over correctness, so 
> for Twisted, this is the "right way" to chain callbacks as far as I'm 
> concerned :) ...

Whatever.  "De gustibus non est disputandum."

Steve.





More information about the Twisted-Python mailing list