Well, I'm going to gather two doubts about python OO here in this message. I use anaconda (python 3.6.1).
I'm trying to make a little project to study object orientation in python 3.6.1. Initially, the problem is in passing the parameters to the constructor.
# coding: UTF-8
from automovel import Veiculo
class Veiculo(object):
#como atribuo valores de instância para essas variáveis como no java, por exemplo?
placa=None
cor=None
cidade=None
#construtor
def __init__(self, placa, cidade, cor):
self.placa=placa
self.cor=cor
self.cidade=cidade
# a linha abaixo não dá erro, mas não usa o construtor
carro=Veiculo
# a linha abaixo dá erro e nem usa o construtor
carro2 = Veiculo("JFW3128", "Salvador", "preto")
The error:
Description Resource Path Location Type Unresolved import: Vehicle automovel.py / automoveis line 7 PyDev Problem
Without the import line, it gives the error:
Description Resource Path Location Type Undefined variable: Vehicle automovel.py / automoveis line 13 PyDev Problem
Note, the filename is automovel.py. I use the eclipse IDE with pydev installed.
I know there are so many theories in OO, like in the link:
I prefer to stick to the concrete part anyway.
In this link, it seems to me that python OO works quietly (python v2):
Print a list of objects as a string in Python
Already the same question below was not a return of user satisfaction: