On Mon, Dec 26, 2011 at 12:17 AM, Roy Smith <r...@panix.com> wrote: > Just for fun, I tried playing around with subclassing NoneType and > writing an __eq__ for my subclass. Turns out, you can't do that: > > Traceback (most recent call last): > File "./none.py", line 5, in <module> > class Nihil(NoneType): > TypeError: Error when calling the metaclass bases > type 'NoneType' is not an acceptable base type
Yes; unfortunately quite a few Python built-in classes can't be subclassed. It's an unfortunate fact of implementation, I think, rather than a deliberate rule. But then, what would you ever need to subclass None for, other than toys and testing? ChrisA -- http://mail.python.org/mailman/listinfo/python-list