On 04/08/2010 12:22 PM, varnikat t wrote:
it gives me this error

TypeError: coercing to Unicode: need string or buffer, list found
Thanks for the help.it detects now using glob.glob("*.*.txt")
Can u suggest how to open and read file this way?

*if glob.glob("*.*.txt"):
             file=open(glob.glob("*.*.txt"))

             self.text_view.get_buffer().set_text(file.read())
         else:
             file=open(glob.glob("*.*.html"))

             self.text_view.get_buffer().set_text(file.read())

glob() returns a list of matching files, not a string. So you need to iterate over those files:

  filenames = glob.glob('*.*.txt')
  if filenames:
    for filename in filenames:
      do_something_text(filename)
  else:
    for filename in glob('*.*.html'):
      do_something_html(filename)

-tkc



--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to