On Tue, 8 Jun 2010 02:03:18 am pyt...@bdurham.com wrote: > Here's why I'm confused. The following paragraph from TFM seems to > indicate that old style classes are the default:
Yes, if you don't inherit from object, or another class that inherits from object (like the built-ins), you get an old-style class. > Yet TFM for 2.6.5 shows all class examples without specifying a > parent class. > http://docs.python.org/tutorial/classes.html As the docs also say, they were mostly written before the existence of new-style classes, and they haven't been updated to show the new syntax. Since Python 3.0 will make such a change obsolete, they will probably never be updated. > I've been taught that the proper way to create new style classes has > been to always specify an explicit "object" parent class when > creating a new class not based on other classes. > > Somewhere along the line I seemed to have missed the fact that it is > no longer necessary to define classes with 'object' as a parent in > order to get a new style class. That only holds for Python 3.x, since old-style classes don't exist any longer. > In other words, it seems that the following are now equivalent: > > class Name: > > -AND- > > class Name( object ): Only in Python 3.x. > My impression was the "class Name:" style created an old style class. Only in Python 2.x (and 1.x, but who still uses that?). -- Steven D'Aprano _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor