I have two classes. A vehicle class and a car class. My vehicle class does not have any attributes so I can call it without any arguments. Same for my car class. The car class is a sub class for vehicle class.
In my vehicle class I have a variable assigned a string with some text. How can my sub class car inheritance that variable?
Code:
class Vehicle(object):
    def __init__(self):
        self.__astring = 'Hello'
    def get_string(self):
        print self.__astring
class Car(Vehicle):
    def __init__(self):
        Vehicle.__init__(self)
        # Here I need to make a working variable
        self.__car_string = self.__astring
        self.__car_string2 = ' Again'
        self.__big_string = self.__car_string + self.__car_string2
    # This method should print 'Hello Agan'
    def get_car_string(self):
        print self.__big_string
string1 = Vehicle()
string1.get_string()    # This prints Hello
string2 = Car()
string2.get_car_string()    # This should print Hello Again
When I run the code, I get:
AttributeError: 'Car' object has no attribute '_Car__astring'
I do understand why, but I do not know how to inherit that variable with the string.
 
     
     
    