trailing underscores naming convention_

Albert Visser albert.visser at gmail.com
Fri May 9 10:24:17 EDT 2014


On Fri, 09 May 2014 12:22:56 +0200, Metallicow <metaliobovinus at gmail.com>  
wrote:

> On Friday, May 9, 2014 3:10:26 AM UTC-6, Peter Otten wrote:
>> 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.
>>
>> Working with multiple names with small differences is error-prone.

Definitely.

>
> Anyway, the small snippet just shows that this can be done, but the  
> actual
> question you replied to you left unanswered. It is about the trailing  
> underscores.
>

It's not an "official" convention I think, but a (single) trailing  
underscore is mainly meant to create something that is close to an  
original definition without shadowing it.
If you subclass an object and bind a thusly underscored method to an event  
to which the original is already bound in the superclass's __init__  
method, they are both getting called on the event unless you do not call  
the superclass's __init__() in your own __init__().

-- 
Vriendelijk groeten / Kind regards,

Albert Visser

Using Opera's mail client: http://www.opera.com/mail/



More information about the Python-list mailing list