<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Nov 19, 2014 at 11:14 AM, Skip Montanaro <span dir="ltr"><<a href="mailto:skip.montanaro@gmail.com" target="_blank">skip.montanaro@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">I discussion on the code-quality list got me thinking. Suppose I have<br>
an old-style class in a 2.x app:<br>
<br>
class Foo:<br>
  def __init__(self):<br>
    blah blah blah<br>
<br>
I still use 2.x exclusively, but anytime I run pylint over a bit of<br>
code and it complains that Foo is old-school, I make the obvious<br>
change to inherit from object. While I do this mostly to shut up<br>
pylint so I can focus on more serious messages, I must admit I have<br>
never experienced any problem changing from old-style to new-style<br>
classes. Under what circumstances might this be problematic?<br></blockquote><div><br></div><div>Under most common cases, its as trivial as just subclassing object, however there are some oddities:</div><div><ul><li>The main case errors may pop up is with multiple inheritance (MRO was changed).</li><li>If you are accessing or have defined magic methods.</li><ul><li>For example, overriding __call__ on a specific instance will no work with new-style classes, but will work with old-style classes. Defining it on the class (the common case) works the same in both cases.</li><li>A number of new magic properties were added, __slots__ and __mro__. So if those are being defined (they shouldn't - all dunder names are reserved by Python) it could change behavior oddly.</li></ul></ul><div>It looks like <a href="http://stackoverflow.com/questions/54867/old-style-and-new-style-classes-in-python">http://stackoverflow.com/questions/54867/old-style-and-new-style-classes-in-python</a> has some decent answers to your question.</div></div></div></div></div>