[Tutor] Creating new files w/o overwriting existing ones
Dick Moores
rdm at rcblue.com
Mon Apr 9 20:19:26 CEST 2007
At 08:19 AM 4/9/2007, Alan Gauld wrote:
>"Dick Moores" <rdm at rcblue.com> 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.
Thanks, Alan. I'll use it.
> > nextSVGnum = max(lstNums) + 1
> > return nextSVGnum
Dick
More information about the Tutor
mailing list