[Twisted-Python] Question : Combining wokel XMPP and twisted.internet.serial
Tim Allen
tim at commsecure.com.au
Thu Dec 22 23:15:29 EST 2011
On Fri, Dec 23, 2011 at 11:09:32AM +0700, bino oetomo wrote:
> the "print self.writethis" do as told
>
> but the "self.serial.write(self.writethis)" line raise an exceptions
> ----------START-------------
> File "./mytac01.tac", line 44, in onMessage
> self.serial.write(self.writethis)
> File
> "/usr/lib/python2.6/dist-packages/twisted/internet/abstract.py", line
> 191, in write
> self._tempDataLen += len(data)
> exceptions.TypeError: object of type 'Element' has no len()
> --------------------------
It looks like "self.writethis" is an Element, not a string. Python's
print statement will automatically call str() on things before it prints
them, but Twisted's .write() methods do not. You'll have to change your
code to something like this:
self.serial.write(str(self.writethis))
Tim.
More information about the Twisted-Python
mailing list