[Python-Dev] PEP 8 updates/clarifications

Nick Coghlan ncoghlan at gmail.com
Tue Dec 13 10:30:31 CET 2005


skip at pobox.com wrote:
>     Nick> Any old code could be fixed by putting "from types import
>     Nick> ClassType as __metaclass__" at the top of the affected modules.
> 
> Which would be, what, 90% of all Python code written that defines classes?

I generally don't allow old-style classes in any code I have control over 
(well, aside from exceptions). Having to type '(object)' all the time is 
annoying, but less annoying than trying to figure out which set of semantics a 
given class is using. My interpreter startup script even includes 
"__metaclass__ = None" in order to disable the implicit metaclass.

I think it's an artifact of only seriously starting to use Python with version 
2.2.2 - I don't really understand how old-style classes work, so I try to 
avoid using them.

However, you raise a fair point, which is why I raised the suggestion of 
respecting a "__metaclass__" definition in the builtins, allowing application 
developers to perform their own new-style class smoke test prior to Py3k.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://www.boredomandlaziness.org


More information about the Python-Dev mailing list