RE: python question

  • From: "Ken Perry" <whistler@xxxxxxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Tue, 16 Dec 2008 20:20:35 -0500

You should not need to do io.open  The following works

Log=open("test.log","w")
Log.write("one line\n")
Log.close()

I couldn't even import io so maybe it's just it thinks io is a library and
you're not getting the error.

Ken

-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Tyler
Littlefield
Sent: Tuesday, December 16, 2008 6:04 PM
To: programmingblind@xxxxxxxxxxxxx
Subject: python question

I'm not sure if this is a python bug, or if I'm doing something wrong.
I've opened a file with io.open, and it seems to work:
  log=io.open("TDLynk.log","w")
then I write something with:
log.write("Hello world!")
I get this error:
File "C:\code\tdLynk\logger.py", line 12, in WriteLog
log.write(input)
File "C:\Python26\lib\io.py", line 1487, in write
s.__class__.__name__)
TypeError: can't write str to text stream
..why not?


Thanks,
Tyler Littlefield
email: tyler@xxxxxxxxxxxxx
web: tysdomain-com
Visit for quality software and web design.
skype: st8amnd2005

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: