Python's annoyance.

Jeremy Bowers jerf at jerf.org
Thu Nov 25 00:54:20 EST 2004


On Wed, 24 Nov 2004 10:47:11 -0800, caroundw5h wrote:
> Serioulsy, one of python's main selling points is its elegant syntax, non
> perl like, non C like. If it can't live up to it. I guess i might as well
> use perl or ruby or server side javascript.

There's a rather large difference between

@require_int
@dynamic_dispatch('add', int)
@author("Steven Q. Dude")
@whack_a_hacka_ding_dong(with_fruit=True, sledgehammer=5)
@register(zodb & mysql_storage)
def increment(i):
	return i + 1

and

@require_int
def advanceCounter(index):
	objToAdvance = objStorageArray[index]
	obj.prep(prepType = ADVANCE)
	try:
		obj.advance(1)
	except IOError:
		obj.lazyAdvance(1)
	
	return obj

One guess which is the more common case.

I can make any language look bad by focusing on the nasty cases. I mean,
why not complain about

p=lambda n,s=2,np=lambda s,f:reduce(lambda x,y:x and y,map(lambda
  x,y:x%y,[s+1]*(s/2),range(2,s/2+2)))and s+1or f(s+1,f
  ):n>0and[s]+p(n-1,np(s,np))or[]

(http://groups.google.com/groups?hl=en&lr=&c2coff=1&frame=right&th=5c8439bf5fa72cde&seekm=000001bd7a3a%24f205cc40%2418472399%40tim#link3)

Obviously, any language that allows that isn't clean.

You have to take the gestalt of real code written in the language, not
contrive cases focusing on the worst part of the language. Python's near
the top of the heap. Javascript would fare better if so many inexperienced
programmers weren't bashing away in it, and if so many extant programs in
it weren't bogged down by browser checking code brought on by wildly
divergent DOMs. 

If you insist on using such faulty metrics, though, hie thee hence to
Perl, that epitome of elegant syntax and more power to you. I leave you
with this closing benediction in honor of the might syntactical
cleanliness of Perl:

@==sort@$=map$_.shift@=,@@for@@=/\pL|,/g;$_=@$[$_]

(http://perlgolf.sourceforge.net/cgi-bin/PGAS/post_mortem.cgi?id=11)
(http://perlgolf.sourceforge.net/TPR/0/6/)




More information about the Python-list mailing list