why are people still using classic classes?
Steve Holden
steve at holdenweb.com
Fri Jan 14 16:51:44 EST 2005
Peter Hansen wrote:
> 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?
>
That's not really an issue unless there's a diamond-shaped inheritance
graph and linearisation of the the super classes is required to ensure
that things stay sane. Remembering that the MO for classic classes and
types are rather different, how many cases do you think it will matter?
regards
Steve
--
Steve Holden http://www.holdenweb.com/
Python Web Programming http://pydish.holdenweb.com/
Holden Web LLC +1 703 861 4237 +1 800 494 3119
More information about the Python-list
mailing list