[Python-ideas] comparison of operator.itemgetter objects

Paul Moore p.f.moore at gmail.com
Mon Apr 2 13:44:39 CEST 2012

On 2 April 2012 10:38, Steven D'Aprano <steve at pearwood.info> wrote:
> TypeError: type 'operator.itemgetter' is not an acceptable base type

Quite apart from the question of whether you might want to subclass
operator.itemgetter, that's a really rubbish error message. Why is it
not acceptable?

Searching the source, it appears that types can say they can't be
subclassed by setting Py_TPFLAGS_BASETYPE, so maybe a better error
would be "the designer of type '%s' has disallowed subclassing". Still
doesn't say why they did, but at least it gives a hint as to what's
going on...


More information about the Python-ideas mailing list