why are people still using classic classes?

Peter Hansen peter at engcorp.com
Thu Jan 13 08:41:06 EST 2005


Paul Rubin wrote:
> Simon Wittber <simonwittber at gmail.com> writes:
> 
>>>Is there a reason NOT to use them?  If a classic class works fine, what
>>>incentive is there to switch to new style classes?  
>>
>>Perhaps classic classes will eventually disappear?
> 
> It just means that the formerly "classic" syntax will define a
> new-style class.  Try to write code that works either way.

Unfortunately, if we should follow the recent advice about
always using "super()" in the __init__ method, it's hard
to do what you suggest (though it sounds like good advice)
without resorting to extreme ugliness:

 >>> class Classic:
...   def __init__(self):
...     super(Classic, self).__init__()
...
 >>> c = Classic()
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "<stdin>", line 3, in __init__
TypeError: super() argument 1 must be type, not classobj

Could classic classes ever be removed without us having manually
to fix all __init__ calls to the superclass?

-Peter



More information about the Python-list mailing list