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


Groups > comp.lang.python > #30097

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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.mixmin.net!hq-usenetpeers.eweka.nl!81.171.88.15.MISMATCH!eweka.nl!lightspeed.eweka.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'syntax': 0.03; 'supported,': 0.07; 'python': 0.09; 'sep': 0.09; 'code?': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'happily': 0.16; 'new-style': 0.16; 'old-style': 0.16; 'subclassing': 0.16; 'subject:class': 0.16; 'wed,': 0.16; 'wrote:': 0.17; 'widely': 0.17; 'class.': 0.23; 'header:In-Reply- To:1': 0.25; 'am,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'implicitly': 0.29; 'class': 0.29; 'classes': 0.30; "aren't": 0.33; 'to:addr:python-list': 0.33; 'received:google.com': 0.34; 'subject:?': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'two': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'to:addr:python.org': 0.39; 'subject:-': 0.40; 'header:Received:5': 0.40; '26,': 0.65
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=xGe30CwPjTl2W86sLWEmpy3qkadIQ642OAdEfnJwAPg=; b=bTJUz+FLDa317r+9kXiDs03lxytnvoawCKdkllTKwuSfECJCBtvvfD2cPDXKFXMaCB 5d1bVndLU+zC1mpVCcWxbINoWQ8V8QSGvUGLRH9RI+3h/QjuE5ijNDRa/EAEYFdI83D8 UX3Skw57VQHS9Vmuf6xwhKV2tRN6SRCx7aB9LhJbplE07vXgl4xlUTcdJ9n04U9TE/qi lZpj6BkKLQ09g3NaQCX4armAfXAnwbsuWYkM/+OU7lO8xo/qwMKzJw47UPO+d1khTNEx SRTovt3GF9nee9IpctVE5tR9kscYmOpQLLKpr8QskgvpeB52D2CKe7NalSPUFTH6zZfE nV6g==
MIME-Version 1.0
In-Reply-To <2e8a9e88-9e7e-43f7-a070-ea9054e625f2@googlegroups.com>
References <2e8a9e88-9e7e-43f7-a070-ea9054e625f2@googlegroups.com>
Date Wed, 26 Sep 2012 01:05:23 +1000
Subject Re: new-style class or old-style class?
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1344.1348585527.27098.python-list@python.org> (permalink)
Lines 10
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1348585527 news.xs4all.nl 6965 [2001:888:2000:d::a6]:51245
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:30097

Show key headers only | View raw


On Wed, Sep 26, 2012 at 12:44 AM, 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!!

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

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