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


Groups > comp.lang.python > #81037

Potential pitfalls when going from old-style to new-style classes

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news2.arglkargh.de!news.albasani.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <skip.montanaro@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.049
X-Spam-Evidence '*H*': 0.90; '*S*': 0.00; 'suppose': 0.07; 'classes.': 0.09; 'def': 0.12; 'mostly': 0.14; 'new-style': 0.16; 'old-style': 0.16; 'subject:when': 0.16; 'discussion': 0.18; 'bit': 0.19; '2.x': 0.24; 'skip': 0.24; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'object.': 0.31; 'class': 0.32; 'run': 0.32; 'skip:_ 10': 0.34; 'subject:from': 0.34; 'problem': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'changing': 0.37; 'list': 0.37; 'subject:new': 0.38; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'anytime': 0.60; 'more': 0.64; 'obvious': 0.74; 'subject:Potential': 0.91; 'serious': 0.97
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=SMDteZDIA8TuIUh10ZHFIMGlXsHUG7/o+PkgwgmdiwA=; b=N5FbLGr+nJdXipwkbqjJFRYfjBj1CKzRf+kwG3LqO70d7LTVW9YW4ugmofyQ+3Dmkw nRGYr3fTY6hS3HVfWayrjdnxU+FHwfGbUu4LJH/ktquuGq+scQjVrRMKXVfVtjy1FMin yWxKsY9E0Qlq1FB0SKyJo0ksaolQwnB8QZQHjDZFY75vYb/nhX3Ub4PtH9M851qB9AJc MQJ//TPls4sSOGg5FovHxEgYyjDiRWfp5HysLt43TpcSSHIg0xi8d8OrGoI2d+NEujCD +80YPYy6SBefS4TFkPbHIrPs08gUMCBlQqkmoAYxK+aZEubtyGB6DWbd825HvajZoxpM IEfg==
MIME-Version 1.0
X-Received by 10.107.41.148 with SMTP id p142mr2322861iop.64.1416424500103; Wed, 19 Nov 2014 11:15:00 -0800 (PST)
Date Wed, 19 Nov 2014 13:14:59 -0600
Subject Potential pitfalls when going from old-style to new-style classes
From Skip Montanaro <skip.montanaro@gmail.com>
To Python <python-list@python.org>
Content-Type text/plain; charset=UTF-8
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 <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.15997.1416424509.18130.python-list@python.org> (permalink)
Lines 17
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1416424509 news.xs4all.nl 2829 [2001:888:2000:d::a6]:44127
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:81037

Show key headers only | View raw


I discussion on the code-quality list got me thinking. Suppose I have
an old-style class in a 2.x app:

class Foo:
  def __init__(self):
    blah blah blah

I still use 2.x exclusively, but anytime I run pylint over a bit of
code and it complains that Foo is old-school, I make the obvious
change to inherit from object. While I do this mostly to shut up
pylint so I can focus on more serious messages, I must admit I have
never experienced any problem changing from old-style to new-style
classes. Under what circumstances might this be problematic?

Thx,

Skip

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


Thread

Potential pitfalls when going from old-style to new-style classes Skip Montanaro <skip.montanaro@gmail.com> - 2014-11-19 13:14 -0600

csiph-web