I wonder if it makes sense to warn about misspelled dunder names. I tried pylinting (1.1.0, sorry, it's what I have here at work) and flake8ing (2.0) this:
class Foo(object):
def __init_(self):
self.x = 0
def _add_(self, other):
return self.x + other.x
Pylint complained about attribute x not being defined in __init__, but that's a rather indirect message. It failed to say anything about _add_. Flake8 said nothing.
Is this a common enough problem that these sort of tools should warn about mistakes in the leading/trailing underscore count of otherwise dunder attributes?
Skip
---------- Forwarded message ----------
From:
protestmailself <protestmailself@gmail.com>Date: Fri, Nov 21, 2014 at 1:56 AM
Subject: Re: The doc demo have some problems
To: webmaster <
webmaster@python.org>
Hi:
I make a mistake using
_init_ not the __init__
protestmailself
Date: 2014-11-21 15:30
Subject: The doc demo have some problems
def _init_(self, realpart, imagpart):
x = Complex(3.0, -4.5) x.r, x.i
I got the error: TypeError: this constructor takes no arguments
i think this is a mistake as the demo not define a constructor, but use a constructor with two arguments.
Change to this can be passed.
class Complex:
def _init_(self, realpart, imagpart):
x = Complex()
x._init_(3.0, -4.5)
x.r, x.i
Best regards
protestmailself