new-style class or old-style class?

Chris Angelico rosuav at gmail.com
Tue Sep 25 11:05:23 EDT 2012


On Wed, Sep 26, 2012 at 12:44 AM, Jayden <jayden.shui at gmail.com> wrote:
> In learning Python, I found there are two types of classes? Which one are widely used in new Python code? Is the new-style much better than old-style? Thanks!!

Definitely go with new-style. In Python 3, old-style classes aren't
supported, and the syntax that would create an old-style class in
Python 2 will implicitly create a new-style class. (Explicitly
subclassing object still works in Py3, so you can happily use that
syntax for both.)

ChrisA



More information about the Python-list mailing list