Your subclass strdoes not override format, so when you call formatin one of its instances, it just uses one inherited from strthat uses the self"internal value as str", i.e. the string form of what you passed offset().
To change this internal value, you can override __new__, for example:
class offset(str):
def __init__(self, x):
self.x = x
def __new__(cls, x):
return str.__new__(cls, '{' + str(int(bool(x))) + '}')
for i in (0, 1):
x = offset(i)
print x
print repr(x)
print x.format('first', 'next')
emits
{0}
'{0}'
first
{1}
'{1}'
next
, __repr__, , __new__, , str .