abc don't play well with private method

mouadino mouadino at gmail.com
Mon May 17 09:35:42 EDT 2010


Hello
and thanx for your answer it's was very helpful

but just to clear some thinks :

> There's no such thing as a "private" attribute in Python. The
> name-mangling mechanism invoked by "__name" is really meant to avoid
> accidental redefinition of the attribute in a derived class.

> In this case, your attribute is expected to be redefined, so you
> definitly don't want any name mangling here.

yes , but what i have supposed is that the name mangling will not be
applied when you use abc especially when you decorate the function
with abc.abstractmethod , because it's will(should) be redefined (so
something is wrong with the abc module) .

> Also and FWIW, the naming convention for "implementation attributes" is
> a single leading underscore

sorry but i don't agree on this. the two underscore (__) are used in
classes level for defining private method in the python way, and the
one underscore (_) is used in the module level :

"""Prepending a single underscore (_) has some support for protecting
module variables and functions (not included with import * from).
Prepending a double underscore (__) to an instance variable or method
effectively serves to make the variable or method private to its class
(using name mangling). """
src:http://google-styleguide.googlecode.com/svn/trunk/pyguide.html

> >     def close(self):
>
> >         self.close()
>
> >     def quit(self):
>
> >         self.quit()
>
> Don't you see kind of a problem here ? Something like, say, an infinite
> recursion ?

yep , thanx





More information about the Python-list mailing list