Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #30195

Re: new-style class or old-style class?

From Roy Smith <roy@panix.com>
Newsgroups comp.lang.python
Subject Re: new-style class or old-style class?
Date 2012-09-26 09:12 -0400
Organization PANIX Public Access Internet and UNIX, NYC
Message-ID <roy-7EBE6F.09123326092012@news.panix.com> (permalink)
References <2e8a9e88-9e7e-43f7-a070-ea9054e625f2@googlegroups.com>

Show all headers | View raw


In article <2e8a9e88-9e7e-43f7-a070-ea9054e625f2@googlegroups.com>,
 Jayden <jayden.shui@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!!

If you're just learning Python 2.x, you might as well use new-style 
classes, since that's what all classes are in 3.x.

On the other hand, if you're just learning, it probably doesn't matter 
which kind you use.  Until you get into some pretty sophisticated stuff, 
you won't notice any difference between the two.

On the third hand, all it takes to create a new-style class is to have 
it inherit from object.  It's no big deal to write

>>> class Foo(object):

instead of just

>>> class Foo:

so you might as well use new-style classes :-)

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

new-style class or old-style class? Jayden <jayden.shui@gmail.com> - 2012-09-25 07:44 -0700
  Re: new-style class or old-style class? "Littlefield, Tyler" <tyler@tysdomain.com> - 2012-09-25 09:02 -0600
  Re: new-style class or old-style class? Chris Angelico <rosuav@gmail.com> - 2012-09-26 01:05 +1000
  Re: new-style class or old-style class? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-09-25 16:20 +0000
    Re: new-style class or old-style class? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-09-25 19:45 +0100
  Re: new-style class or old-style class? Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-09-25 12:33 -0400
  Re: new-style class or old-style class? Ramchandra Apte <maniandram01@gmail.com> - 2012-09-26 05:59 -0700
  Re: new-style class or old-style class? Roy Smith <roy@panix.com> - 2012-09-26 09:12 -0400
  Re: new-style class or old-style class? wxjmfauth@gmail.com - 2012-09-26 13:15 -0700
    Re: new-style class or old-style class? alex23 <wuwei23@gmail.com> - 2012-09-26 17:30 -0700

csiph-web