![]() |
Class Object hellp - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Class Object hellp (/thread-14795.html) |
Class Object hellp - Dneal620 - Dec-17-2018 Hello, I am new to python and having a few problems I was hoping to find some help with on here. I am creating a class object and for some reason when I try to create the object I gives an error saying invalid argument. I've created a file called students.py holding the following information: class Student: def _init_(self, name, major, gpa): self.name = name self.major = major self.gpa = gpaAnd another file named app.py holding the following code: from students import Student Student1 = Student("Dan", "CNS", 3.6) print(Student1.name)When app.py is run I get the following error message: Any help would be much appreciated, ive been working on it for a couple days and am at a loss. I can create a object and then pass data into it using the following: Student1 = Student() Student1.name = "Dan" Student1.major = "CNS" Student1.gpa = 3.5I just cant figure out why I cant pass arguments to the object at creation.\ Thanks again for any help that anyone can give me and my apologies for the messy post, this is my first time posting on a forum for help. RE: Class Object hellp - micseydel - Dec-18-2018 __init__ has two underscores on each side, not one. |