[Tutor] padding frames

Daniel Ehrenberg littledanehren at yahoo.com
Sun Jan 11 14:29:47 EST 2004

Christopher Spears wrote:
> Hmmm...
> zfill is a great tool, but how would I go about
> isolating the part of file's name (DSCN-2.JPG) that
> I
> would need?  My first idea is to somehow get the
> files
> (or their names anyway) into a list as strings:
> x = ['DSCN-2.JPG', 'DSCN-11.jpg', 'DSCN-101.JPG',
> 'DSCN-2302.JPG']
> Then somehow strip off the parts I don't need and
> run
> zfill on the numbers:
> >>>'DSCN-' + x[0][5].zfill(4) + '.JPG'

If you wanted to let that work for all of them, you
should probably do:

>>> 'DSCN-' + x[0][5:-4].zfill(4) + '.JPG'

Is that what you wanted?

Daniel Ehrenberg

Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes

More information about the Tutor mailing list