I am trying to find out if a python class can have private & public member variables or are all class variables(self) variables public?
Is there a way to make a class variable private in python?
for example; if I have this class, all the variables within that class(the self. ones) are public, correct? Is there a way to make them private?
class MyClass: def __init__( self, id ): self.id = id self.name = "blah" def set_name( self, new_name ): self.name = new_name def get_name(): return self.name class = MyClass( 1, "hj" ) name = class.get_name() # I can get name this way bad_way_name = class.name # I dont want to be able to get the name this way