combining the best of both worlds of nick using a faster list comp and brett using os.path.splitext():>>> files = ['DSC1.JPG', 'DSC2.JPG', 'DSC3.JPG']>>> newFiles = [os.path.splitext
(f)[0] for f in files]>>> print newFiles['DSC1', 'DSC2', 'DSC3']cheers,-- wesley- - - - - -
> i create a list of all JPG files with:
> >>> list = glob.glob('*.JPG')
> the content of 'list' is now:
> >>> print list
> ['DSC1.JPG', 'DSC2.JPG', 'DSC3.JPG']
>
> but what i want is this type of list:
> ['DSC1', 'DSC2', 'DSC3']
I would make use of os.path.splitext, which
Hi marc,
>
> i create a list of all JPG files with:
> >>> list = glob.glob('*.JPG')
> the content of 'list' is now:
> >>> print list
> ['DSC1.JPG', 'DSC2.JPG', 'DSC3.JPG']
>
> but what i want is this type of list:
> ['DSC1', 'DSC2', 'DSC3']
> i.e. the names w/o the file e
hi.
i create a list of all JPG files with:
>>> list = glob.glob('*.JPG')
the content of 'list' is now:
>>> print list
['DSC1.JPG', 'DSC2.JPG', 'DSC3.JPG']
but what i want is this type of list:
['DSC1', 'DSC2', 'DSC3']
i.e. the names w/o the file extension.
what's the easi