Alex Hunsley wrote:
Pretty simple seeming question, but can't find answer via google or docs...

I am using urllib2 as follows:

 handle = urlopen(req, postdata)         # and URL to return a handle on
 ...
 print handle.info()

the print statement prints out the headers:

Content-Type: text/html;charset=ISO-8859-1
Content-Length: 2845
Date: Tue, 01 Feb 2005 12:40:28 GMT
Server: Apache Coyote/1.0
Connection: close

which is the string I want to use.
However, if I write a function call using this:

  log(handle.info())

I get this:

 TypeError: cannot concatenate 'str' and 'instance' objects

(The log function expects a string)
What is the magic incantation to get the string I want so I can pass it to my function?
I've tried repr() but that isn't it (I suspected it wouldn't be).
I suppose I'm looking for the equivelant of Java's toString() method...


thanks!
alex





use:

log(str(handle.info()))

str creates a string object from a supplied object with a __str__ method. I think print calls str on what it is going to print



--
--------------------------------------
 Ola Natvig <[EMAIL PROTECTED]>
 infoSense AS / development
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to