How to open and read an unknown extension file

varnikat t varnikat22 at gmail.com
Thu Apr 8 11:30:46 EDT 2010


I am trying to do this
if os.path.exists("*.*.txt"):
            file=open("*.*.txt")
            self.text_view.get_buffer().set_text(file.read())
else:
            file=open("*.*.html")
            self.text_view.get_buffer().set_text(file.read())

It gives error *.*.txt not existing....There are two files in the folder
testing.pnm.txt
and testing.pnm.html
How to make it open any name and extension file and read it?

Regards
Varnika Tewari
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100408/bbcf154e/attachment.html>


More information about the Python-list mailing list