[Tutor] Determine Filetype

admin at gg-lab.net admin at gg-lab.net
Sat Sep 19 17:36:31 CEST 2009


2009/9/19 Sander Sweers <sander.sweers at gmail.com>:
> 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?
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>

Sander, sorry for the top-posting, it's the default in GMail. This is
one of my first times in a mailing list, so it's possible i'm doing
something wrong. Sorry again for it.

I've replied to my mail, as i've found what i was looking for:

if OBJECT in LIST:

Well, but i'd like to read the page of the python tutorial regarding
this. I'm not able to locate it. Can you help me?

Thankyou


More information about the Tutor mailing list