Question on style.
pduffin at hursley.ibm.com
Tue Sep 12 10:26:56 CEST 2000
Rainer Deyke wrote:
> "Alex" <cut_me_out at hotmail.com> wrote in message
> news:etd7l8isrw6.fsf at oliver.mit.edu...
> > # Separate the triple of scores for each sequence into separate parallel
> > # lists for each frame.
> > frames = [[score[frame] for score in scores] \
> > for frame in range(3)]
> I find the order of list comprehensions (with the for part after the
> expression) weird, but otherwise don't have any trouble reading the above.
> It's compact, which is good, even when it takes more effort to comprehend
> each individual line.
> Compare the long version:
> frames = 
> for frame in range(3):
> tmp = 
> for score in scores:
> Each line here is easier to read, but the large number of lines and the
> temporary variable make the whole thing harder to understand, IMO.
IMO the long version is easier to read than the short version because
there is less magic going on. The more you use something such as list
comprehensions the easier it will become to understand them.
Any one like to comment on why this particular order was chosen over
the more 'readable' one of for first then expression.
How would you 'say' the above list comprehension ?
More information about the Python-list