[Python-ideas] Decorator syntax restriction

Stephen J. Turnbull stephen at xemacs.org
Mon Sep 7 04:13:09 CEST 2009


Daniel Fetchinson writes:

 > >> What makes you think that if something is 'more verbose' it is 'less
 > >> pythonic'? I actually like the fact that python doesn't try condensing
 > >> everything into one-liners and special symbols.

Yes.

 > > Agreed. Readability, not succinctness, is what's pythonic. Being
 > > succinct usually - but not always - improves readability.

Yes.

 > >> I never really understood this need for being not verbose, but it does
 > >> periodically come up on this list (and pretty much on every other
 > >> programming list).
 > >> Your fingers get tired?

Yes.  See Jan Kaliszewski's post in the "possible attribute-oriented
class" thread.  His reasoning is valid, though I don't sympathize with
it personally.

 > >> It takes too long to read an extra line?

Yes, when "too long" has the semantics "I read this repeatedly in a
short space and don't need to see the whole thing over and over
again.  In fact, it gets in my way when reading an 'array' of the sme
idiom."

This is what Paul Graham means by (expressive) power, I believe.  He
mentions metrics like number of characters or lines, but he says what
he really wants is something like the number of leaves in the AST.

If the "this" is something local, then you use a function (or
sometimes a macro if available) at that level of locality.  But if the
idiom appears across many programs, then it may be a good idea to turn
it into a standard builtin, or even syntax.  I believe this is the
gist of Graham's argument, and it's very close to the criteria for
adding syntax in the Zen (actually, the apocrypha, stuff like "not
every three-line function needs to be a builtin" aren't canonized).

 > >> You are running out of space on your harddrive?
 > >> It takes too long to transfer the source file over the network
 > >> because of the extra line?

Both of those are silly.  If you use compression, it will work out
about the same anyway.<wink>

 > >> Honestly, why do some people set for themselves the goal of "let's
 > >> have as few characters in a source file as possible"?

Mostly the ones who show up on Python lists don't have such a goal.
They just want the ache in their hands and arms to go away, one
unnecessary character at a time.

 > > Paul Graham (generally a very sharp guy) summarizes most of the
 > > reasons in http://www.paulgraham.com/power.html.
 > 
 > Thanks, this answers my question why people think this way. Although
 > I'm still totally convinced that guys like Paul Graham, or anybody
 > else who believes in shorter code, are misguided.
 > 
 > > I provide my attempt at a counterargument in
 > > http://www.mired.org/home/mwm/papers/readability.html.
 > 
 > Yep, I more-or-less agree with you.

But Paul Graham does, too, AFAICS.

ISTM that what Paul G. doesn't get is that Paul P.'s epigram is more
along the lines of Emerson's epigram.  To put it in the same style, "A
bogus succinctness is the hobgoblin of L2-cache-deprived minds (and
RSI-hobbled wrists)."  To me, the argument on "mired" seems quite
complementary to the argument Graham makes, in that it shows how
Python actually is succinct in the sense that Graham proposes, despite
not minimizing character, token, or line counts.



More information about the Python-ideas mailing list