Well, I've tried both and can't produce what I was doing with the for construct. With a list pl = ['a', 'b', 'c', 'd'] of the path components I'm trying to add justified non repeated path elements, say pl[2] and pl [3] to csvline so that csvline would end up '"",'*x plus '"c","d",'
>>> pl = ['a', 'b', 'c'] >>> csvl = '"",' >>> csvl += '"'.join(pl[0:2]) + '",' >>> csvl '"",a"b",' which is intended to be '"","a","b",' Saving one line of code in this module doesn't mean much, but if it were a efficiency in processing it would? Lee C On Jun 4, 2005, at 6:55 PM, Kent Johnson wrote: > Javier Ruere wrote: > >> for i in range(alvl, clvl): >> csvline = csvline + '"' + pl[i] + '",' >> >> should be replaced by something like the following: >> >> cvsline += '"' + pl[alvl:clvl].join('",') >> > > or maybe more like this: > cvsline += '"' + '",'.join(pl[alvl:clvl]) + '",' > > though if alvl == clvl this will output an empty cell. > > Kent > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor > _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor