If - Or statements

tiissa tiissa at nonfree.fr
Sat Jun 4 09:31:56 EDT 2005


Ognjen Bezanov wrote:
>                 ext = thefile.split('.') #get the file extension
>                 ext[1] =  ext[1].lower() #convert to lowercase

As a side note, ext[1] will be the first extension:

  >>> 'foo.bar.ogg'.split('.')[1]
  'bar'

I'd advise ext[-1], the last element of the splitted list.

  >>> 'foo.bar.ogg'.split('.')[-1]
  'ogg'



More information about the Python-list mailing list