how can we not expose methods in Python and make them private as in Java?
specifically, my scenario involves functions that the user should not be using.
how can we not expose methods in Python and make them private as in Java?
specifically, my scenario involves functions that the user should not be using.
I think the only way to make inaccessible methods is like this
class A:
def some_func(self,*some_Args):
def this_is_innaccessible_function():
return "yellow"
print this_is_innaccessible_function()
however it is also inaccessible to the rest of the class... the only place it is accessible is within some_func
standard convention tells us to mark private funcs with double underscores, this causes some name mangling behind the scenes which makes it marginally more difficult to access from outside the class
class A:
def __private_by_convention(self):
print "this should not be called outside of class...but it can be"