[IronPython] Multiple-inheritance with builtin types

Sanghyeon Seo sanxiyn at gmail.com
Thu Apr 20 09:04:07 CEST 2006


Example code:

class CompatMixin:
    def __getattr__(self, attr):
        if attr == 'string':
            return self
        else:
            raise AttributeError, attr

class CompatString(str, CompatMixin):
    pass

s = CompatString('abc')
print s
print s.string
s.error

The intent is to provide backward-compatibility with previous API, so
that using the string as s and s.string both work. Above code was
modelled after similar code in BeautifulSoup, a popular Python
library.

IronPython says:
NotImplementedError: CompatString: unsupported base type for new-style
class: IronPython.Runtime.ExtensibleString

Seo Sanghyeon



More information about the Ironpython-users mailing list