I am currently learning Python 2.6.5 and I found out about old style classes and new style classes.
I understand that these classes are still existing only for backward compatibility and that they are removed in Python 3.
So the question is this: as a newcomer to the language, do I need to learn about the classic classes?
P.S. I am learning Python 2 because Python 3 is still not fully supported in frameworks and I want to learn some frameworks too. The plan will be to move to Python 3 when frameworks catch up, but until then, do I need to worry about the old style classes?
No. Don't bother. Simply inherit all your classes from
object
(or from classes that inherit fromobject
) and you will be good to go. Then when you transition to Python 3 you can forget that bit of syntax.There's no advantage to using or even learning about old-style classes at this point.
So just make sure all of your class declarations look like this:
(or inherit from something other than
object
which does inherit fromobject
), and then pretend this is the way that it has always been!