Aug-11-2017, 12:46 PM
Hi,
Am new to Python3 (previously Java)
Below I make a class, instantiate it, and then do 2 things I don't understand (see comments)
Appreciate some help - Michael
Am new to Python3 (previously Java)
Below I make a class, instantiate it, and then do 2 things I don't understand (see comments)
Appreciate some help - Michael
class HWClass: def __init__(self): self.__classvar = 3 #private self.printHW() def printHW(self): print("Hello World") hw = HWClass() #Instantiation hw.__classvar = 4 #This suggests I change a private class variable? It doesn't actually change, but the text suggests it does, which is error-prone hw.varxxxx = 9 #How can I use a variable on this class object that is not defined in the class?