[Twisted-Python] My pet peeve ugly coding style

Tommi Virtanen tv at twistedmatrix.com
Thu Jul 10 13:17:59 MDT 2003


On Thu, Jul 10, 2003 at 03:33:26PM -0000, Moshe Zadka wrote:
> > > checkHosts(('moshez.org', 25), ('moshez.org', 22)
> > > ).addCallback(util.println
> > > ).addCallback(lambda _: reactor.stop())
> > 
> > 	*vomit*
> > 
> > d = checkHosts(('moshez.org', 25), ('moshez.org', 22))
> > d.addCallback(util.println)
> > d.addCallback(lambda _: reactor.stop())
> > 
> > 	anyone?
> 
> No.
> The above is the common,

	Unfortunately.

> and correct, coding style.

	Yes, it's legal. It's still ugly.

> It is the very reason .addCallback returns self. 

	Yes, and that's part of the problem; not the reason
	why ugly code should be tolerated.


	I mean, eww yuk. Look at it. ")" at the start of every
	(non-first) line? A special case for the last line?

	 |         |
	 v         v     |
	return foo(      v
	).addCallback(bar
	).addCallback(baz
	).addCallback(quux
	).addCallback(thud
	).addCallback(xyzzy)
	^                  ^
	|                  |


	The prettier alternative isn't even noticably longer,
	and is easier to type even. And the last line isn't
	a special case. And it doesn't separate a return away
	from the end of the functions.


	That snippet looks like the reason I left perl. Stop
	giving me the creeps, and give me code that looks
	simple, regular and easy to scan.

-- 
:(){ :|:&};:




More information about the Twisted-Python mailing list