1
I’m new to programming, but I just came from Java and I’m migrating to Python.. To start I created a simple Person class with 3 attributes and tried to instantiate it to see the syntax, but I just can’t understand why it doesn’t work...
The Class
class Person:
def __init__(self, Name, Age, Height):
self.name = Name
self.age = Age
self.height = Height
The file "Main"
import Person
if __name__ == "__main__":
person = Person("Mateus", 18, 1.8)
print(person.name)
And makes the mistake:
File "c:\Users\Lenovo\Desktop\python\main.py", line 4, in <module>
person = Person("Mateus", 18, 1.8)
TypeError: 'module' object is not callable
Sorry for being stupid and thank you so much for your help.
Typeerror: 'module' Object is not callable
– Mateus Sitta
Vlw kkk am new aq too
– Mateus Sitta
What do you call the file containing the class? It’s a module, and at the top of the other file you need to use
from modulo import Person
instead of what you did.– bfavaretto