trailing underscores naming convention_
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Fri May 9 20:00:00 EDT 2014
On Fri, 09 May 2014 10:35:09 -0600, Michael Torrie wrote:
> On 05/08/2014 11:49 PM, Metallicow wrote:
>> I guess to be more clear here is a small code snippet that shows what
>> is happening more readably. Hence the underscores question.
>
> In a case like this I'd probably prefer to number the methods rather
> than add underscores to the end of the names. My current font, for
> example, connects the underscores together, so it's a bit hard from a
> glance to tell if it's just two underscores or three.
>
> I'd prefer OnLeftDClick1, OnLeftDClick2, OnLeftDClick3, for example.
Yes, this.
I wouldn't say that underscore suffixes are *reserved* only for avoiding
name clashes with keywords and built-ins, e.g. in_ type_ etc., but I
can't think of any other reason why you would want to end an identifier
with an underscore. As for multiple underscores like in__ in___ in____
that's just too hideous for words.
> And I also prefer pep8 method names as well, on_left_dclick1, etc. But
> when the underlying library doesn't follow pep8, then I guess it does
> not matter (self.Bind is from the library I presume).
And again, this.
--
Steven D'Aprano
http://import-that.dreamwidth.org/
More information about the Python-list
mailing list