[Tutor] Pythonese/Efficiency/Generalese critique please

Kent Johnson kent37 at tds.net
Sun Jun 5 00:55:54 CEST 2005


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



More information about the Tutor mailing list