[Tutor] TypeError: not all arguments converted during string formatting

Joel Goldstick joel.goldstick at gmail.com
Mon Jul 9 17:46:35 CEST 2012


On Mon, Jul 9, 2012 at 11:31 AM, Keitaro Kaoru <tokyo.rook at gmail.com> wrote:
> Traceback (most recent call last):
>   File "bot.py", line 351, in <module>
>     mgr.main()
>   File "/home/bot/bot/ch.py", line 1672, in main
>     con._feed(data)
>   File "/home/bot/bot/ch.py", line 628, in _feed
>     self._process(food.decode("latin-1").rstrip("\r\n")) #numnumz ;3
>   File "/home/bot/bot/ch.py", line 643, in _process
>     getattr(self, func)(args)
>   File "/home/bot/bot/ch.py", line 744, in rcmd_u
>     self._callEvent("onMessage", msg.user, msg)
>   File "/home/bot/bot/ch.py", line 1091, in _callEvent
>     self.mgr.onEventCalled(self, evt, *args, **kw)
>   File "bot.py", line 287, in onEventCalled
>     self.invokeListeners(room, evt, *args, **kw)
>   File "bot.py", line 110, in invokeListeners
>     getattr(lis, evt)(self, room, *args, **kw)
>   File "modules/lulz2.py", line 47, in onMessage
>     self.sendObject(room, ret)
>   File "bot.py", line 307, in sendObject
>     obj = obj.__botOut__(self, room)
>   File "/home/bot/bot/tools.py", line 226, in __botOut__
>     return self.html % ca
> TypeError: not all arguments converted during string formatting
>
>
>
>
> class Text:
>         def __init__(self, text):
>                 self.text = text
>
>         def __botOut__(self, mgr, room):
>                 return cgi.escape(self.text)
>
> class Html:
>         def __init__(self, html, *args):
>                 self.html = html
>                 self.args = args
>
>         def __botOut__(self, mgr, room):
>                 if len(self.args) == 0:
>                         return self.html
>                 else:
>                         ca = tuple([cgi.escape(arg) if type(arg) == str else arg for arg in
> self.args])
>                 return self.html % ca
>
> cant seem to find out whats wrong with it

You don't show what self.html is.  It must have the same number of %s
values as the length of ca
> --
> ~~Austin
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor



-- 
Joel Goldstick


More information about the Tutor mailing list