"Protected" access in Python - how?

inheritance, protected, python, python-3.x

Solution

Member access allowance in Python works by "negotiation" and "treaties", not by force.

In other words, the user of your class is supposed to leave their hands off things which are not their business, but you cannot enforce that other than my using `_xxx` identifiers making absolutely clear that their access is (normally) not suitable.

Problem

I would like to set up a class hierarchy in Python 3.2 with 'protected' access: Members of the base class would be in scope only for derived classes, but not 'public'. A double underscore makes a member 'private', a single underscore indicates a warning but the member remains 'public'. What (if any...) is the correct syntax for designating a 'protected' member.

Original source