[issue25652] collections.UserString.__rmod__() raises NameError

Serhiy Storchaka report at bugs.python.org
Sun Mar 6 15:48:11 EST 2016


Serhiy Storchaka added the comment:

What about such example?

>>> class F:
...     def __init__(self, value):
...         self.value = value
...     def __mod__(self, other):
...         if isinstance(other, str):
...             return self.value % other
...         return NotImplemented
... 
>>> from collections import UserString
>>> F('say %s') % UserString('hello')
'say hello'

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue25652>
_______________________________________


More information about the Python-bugs-list mailing list