Python Forum

Full Version: This constructor takes no arguments
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi all,

i am just learning about classes. This a very simplified version of the example i was checking in a book

class Person:
    def __ini__(self, name):
        self.name = name
once i try to create an instance from this class
person1 = Person('John')
i get the following error :

Error:
Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> person1 = Person('John') TypeError: this constructor takes no arguments
can you please advise what is the problem here.
i have read similar thread but in ost of them the user used only single underscore _init_ instead of double __init__

thanks in advance
You are missing the t on init
Quote:
def __ini__(self, name):
Wall

thanks metulburr for the very quick help.
that was a stipid mistake from me :)