[Tutor] Pythonese/Efficiency/Generalese critique please
leec03273 at mac.com
Sun Jun 5 04:27:50 CEST 2005
Well, I've tried both and can't produce what I was doing with the for
With a list pl = ['a', 'b', 'c', 'd'] of the path components I'm
trying to add justified non repeated path elements, say pl and pl
 to csvline so that csvline would end up '"",'*x plus '"c","d",'
>>> pl = ['a', 'b', 'c']
>>> csvl = '"",'
>>> csvl += '"'.join(pl[0:2]) + '",'
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?
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.
> Tutor maillist - Tutor at python.org
More information about the Tutor