I'm using PyCharm 5.0.4 Comunity Edition and Python 2.7.
My code looks like this, in the file carInput.py:
class carInput():
def __init__(self):
self.string = 'hi'
I type the following in the console:
>>> car = carInput.carInput()
>>> car
<carInput.carInput instance at 0x00000000027F3D08>
>>> car.string
Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: carInput instance has no attribute 'string'
I imagined that upon instantiating the carInput object, the init-method will always be executed, and the variable string is declared. However, when I try to access the object's string variable from the console, I am told that my object has no such attribute. What is it I have misunderstood?