type(d) != type(d.copy()) when type(d).issubclass(dict)

kj no.email at please.post
Sun Dec 26 13:37:44 EST 2010



"John O'Hagan" <research at johnohagan.com> writes:

>IMO one of the benefits of subclassing is that you can just "bolt on" 
>additional behaviour without having to know all the inner workings of the 
>superclass, a benefit that is somewhat defeated by this behaviour of builtins.

I agree.  I've read the old post/articles by GvR and other over
how great it will be now that one can subclass Python builtin types
like any other class (GvR even gives explicit examples of this
luscious possibility in his paper on type/class unification).  But
now I'm discovering so many caveats, exceptions, and gotchas about
subclassing builtins that I have to conclude that this much celebrated
new capability is basically useless...  Just like "readability
counts", it is also true that "conceptual clarity" counts, and
treating builtins as classes in Python is the most obfuscated design
I've ever seen.

UserDict, come back, all is forgotten!

~kj



More information about the Python-list mailing list