Hi marc,

> 
> i create a list of all JPG files with:
> >>> list = glob.glob('*.JPG')
> the content of 'list' is now:
> >>> print list
> ['DSC00001.JPG', 'DSC00002.JPG', 'DSC00003.JPG']
> 
> but what i want is this type of list:
> ['DSC00001', 'DSC00002', 'DSC00003']
> i.e. the names w/o the file extension.
> 
> what's the easiest way of doing this?
> 
> marc

You need the split() method.
ie 
>> l = ['DSC00001.JPG', 'DSC00002.JPG', 'DSC00003.JPG']
>> print [i.split('.')[0] for i in l] 

Hth,
Nick .

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to