Is this a dream or a nightmare? (Was Re: XML)

Michal Wallace sabren at manifestation.com
Sun Oct 8 15:11:21 EDT 2000


On Sun, 8 Oct 2000, Alex Martelli wrote:

> > >         themap.setdefault(word,[]).append(fileinput.lineno())
>     [snip]
> > Wait a second. setdefault is new in 1.6/2.0, neither of which
> > are the "real" python yet... So add two lines while themap.setdefault
> 
> 1.6 is the latest released Python, so why wouldn't it be "real"?

You're right. What I was getting at is that that particular feature
really hasn't been around long enough to have been included in any
studies of the language, so it wouldn't have applied in coming to the
conclusion that perl was more concise than python. (meaning just that
the study, if there was one, is outdated)..


> > while(<>){for(split){$i{$_}.=++$L." "}}for(sort keys
> %i){print"$_:$i{$_}\n"}
> 
> I may be missing something, but doesn't the ++ get repeated for each
> incoming word?  If so, then this is building an index of word numbers,
> not of line numbers.  Easy to fix, no doubt.

Ooops. You're right again. :) What do I know? I'm a pythonista, not
japh.. :) .. And I'd hate to be the guy hired six months from now to
come find and fix that line in an 1,000 line perl program.. :)

> Maybe a manager who pays by the line of code (and doesn't have to
> worry about maintenance, because he'll be off to another job by the
> time maintenance is needed) might prefer to purchase code written
> in terms of (few) one-liners.  Why not?

Do people really pay by line of code? I want THAT job.. :)

# old way: for x = 1 to 10

# new way: :)
x = 1
x = 2
x = 3 ...


> However, by this way of counting, just about every Java program,
> for example, can be made a 1-liner: just remove the line-ends and
> change them into spaces (you may have to remove or recode the
> comments ["what comments", one hears...:=)]).

true. I'd never really write code like that.. I just heard it as a
challenge.. :)


> mine based on thinking that this tweak, when well used, can lead to
> programs that are more easily read.  I don't do it in the illusion
> that such "concision" changes anything substantial...

I agree completely.

Reading super-concise perl is (similar to what dave said) like reading
an academic paper. Each line has a lot of information crammed into it.

The more ideas you cram into a line, the harder the code is to read.
That's why I like the idea of encapsulating the tricky stuff in a
friendly method or object.. :)

Cheers,

- Michal
------------------------------------------------------------------------
www.manifestation.com  www.sabren.com  www.linkwatcher.com  www.zike.net
------------------------------------------------------------------------





More information about the Python-list mailing list