"Friend"ing classes in python

calccrypto picture calccrypto · Jun 14, 2011 · Viewed 14.4k times · Source

Is there any way to make certain variables in classes "private" (or whatever self.__var really is) but be accessible to another class, like friends in c++, except in python? I do not want the variables in either class being messed with. Nor do I want to copy the entire code over and convert it for the second class.

Answer

Amber picture Amber · Jun 14, 2011

No, there is not such an option.

Use names that start with single underscores and tell the other people working on your project to not be silly about what they access.