Alan Gauld wrote:
> "Dick Moores" <[EMAIL PROTECTED]> wrote 
> 
>>     lstNums = []
>>     for x in lstSvg:
>>         num = int(x.split('.')[0])
>>         lstNums.append(num)
> 
> This is exactly what a list comp does so you could rewrite it as:
> 
> lstNums = [int(x.split('.')[0]) for x in lstSvg]
> 
> One of the cases where I actually think a list comprehension 
> is more readable than the expanded code.

And from there it is just one more step to skip the list completely:

nextSVGnum = max(int(x.split('.')[0]) for x in lstSvg) + 1

Kent
_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to