Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23189

How to hide Python class method outside the class (and I don't mean "double underscore" protected)

$
0
0

I'm trying to hide a class method if the class is used from outside. I have afunction A that does something and function B that uses A to do something else. E.g.:

class Some_Class:   def funcA():      do something   def funcB():      use funcA() to do this

I want funcA() to be not visible. If I make funcA protected: def __funcA():, fine, it can'tbe accessed from outside, but then funcB() does not execute because it needs funcA().Further, funcA() can still be seen from the outside, even if it's protected the outside can stillsee that "it's there". Is there a way to hide it? so that to the outside doesn't know about it?Why I want this is just that funcA() is unnecessary information to the outside.

What I can do is just bring funcA() outside the class, but is there a way to do it and keep it inthe class?

Follow up: I tried also to make it private with "single underscore" def _funcA(): but that doesn't even seem to do anything.


Viewing all articles
Browse latest Browse all 23189

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>