[Tutor] Determine Filetype

Sander Sweers sander.sweers at gmail.com
Sat Sep 19 17:26:32 CEST 2009


On Sat, 2009-09-19 at 17:20 +0200, admin at gg-lab.net wrote:
> I want to check the extension of an uploaded file. So i've created a
> list with allowed extensions:
> 
> enabled_ext = ['gif', 'jpeg', 'png', 'bmp', 'tiff']

If this does not change make it s tuple. It does not change what is
written below.

> How can i create a simple if that check if the file ext (file_ext) is
> in the list?

The below idle session should help you figure it out.

>>> enabled_ext = ('gif', 'jpeg', 'png', 'bmp', 'tiff')
>>> 'gif' in enabled_ext
True

Greets
Sander

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?



More information about the Tutor mailing list