determining file type

2006-06-14 Thread Ritesh Raj Sarraf
Hi, I have a funtion named unzipper() which does the work of unzipping the files. Is there a way I can identify what is the type of the file which'll be passed to unzipper(). If yes, I'll be able to make out if it's a zip file or a tar or a bz2 file. Thanks, Ritesh --

Re: determining file type

2006-06-14 Thread Maric Michaud
Le Mercredi 14 Juin 2006 11:22, Ritesh Raj Sarraf a écrit : Hi, I have a funtion named unzipper() which does the work of unzipping the files. Is there a way I can identify what is the type of the file which'll be passed to unzipper(). If yes, I'll be able to make out if it's a zip file or

Re: determining file type

2006-06-14 Thread Ritesh Raj Sarraf
But isn't there any library function ? Something like XX.filetype(name) Directory File-Tar File-Zip File-MPEG Ritesh Maric Michaud wrote: Le Mercredi 14 Juin 2006 11:22, Ritesh Raj Sarraf a écrit : Hi, I have a funtion named unzipper() which does the work of unzipping the files. Is

Re: determining file type

2006-06-14 Thread Ritesh Raj Sarraf
Also, f = file ('some_file.jpg') throws an error. str object is not callable Ritesh Maric Michaud wrote: Le Mercredi 14 Juin 2006 11:22, Ritesh Raj Sarraf a écrit : Hi, I have a funtion named unzipper() which does the work of unzipping the files. Is there a way I can identify what

Re: determining file type

2006-06-14 Thread Maric Michaud
Le Mercredi 14 Juin 2006 12:41, Ritesh Raj Sarraf a écrit : Also, f = file ('some_file.jpg') throws an error. str object is not callable stange, did you define a function named file ? You can use open instead. -- _ Maric Michaud _ Aristote - www.aristote.info 3

Re: determining file type

2006-06-14 Thread Diez B. Roggisch
Ritesh Raj Sarraf schrieb: Also, f = file ('some_file.jpg') throws an error. str object is not callable I bet you have rebound file to a string, like this: file = some name And PLEASE don't top-quote: http://www.redballoon.net/~snorwood/quote-rant.shtml Diez --

Re: determining file type

2006-06-14 Thread Marc 'BlackJack' Rintsch
In [EMAIL PROTECTED], Ritesh Raj Sarraf wrote: Also, f = file ('some_file.jpg') throws an error. str object is not callable This happens if you rebind names of builtins. In this case to a string. Don't do that! In [5]:file Out[5]:type 'file' In [6]:file = 'foo.txt' In [7]:file

Re: determining file type

2006-06-14 Thread Sion Arrowsmith
Ritesh Raj Sarraf [EMAIL PROTECTED] wrote: Also, f =3D file ('some_file.jpg') throws an error. str object is not callable You know all the times people say in this group Don't use list or str or file[HINT] or anything else that shadows a built in as a variable name? Now you know why. -- \S --

Re: determining file type

2006-06-14 Thread utabintarbo
http://www.demonseed.net/~jp/code/magic.py -- http://mail.python.org/mailman/listinfo/python-list