This is my folder structure:
├── Basic
├── Coche
│ ├── __init.py__
│ ├── coche.py
├── miPrimerCoche.py
I want to import the class "coche.py" in miPrimerCoche. In coche.py I have this:
class Coche:
def __init__(self, marca, color, caballos):
self.marca = marca
self.color = color
self.caballos = caballos
def datos(self):
return "Este coche es un: " + self.marca + \
" de color: " + self.color + " y con: " + str(self.caballos) + " caballos"
And, in miPrimerCoche I have this code:
from Coche import coche
miMercedes = coche("Toyota", "verde", 50)
print miMercedes.marca
print miMercedes.datos()
Then, when I run miPrimerCoche, I get this error:
Traceback (most recent call last):
File "/Users/personalUser/PycharmProjects/untitled/Basic/importar_clase.py", line 3, in <module>
miMercedes = coche("Toyota", "verde", 50)
TypeError: 'module' object is not callable
Basic is the src folder (it is in blue color), what I can do?
I resolved with
miMercedes = coche.Coche(par1, par2, par3...)
but I don´t know if is the good way to do it.