By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,222 Members | 2,416 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,222 IT Pros & Developers. It's quick & easy.

ypeError: this constructor takes no arguments

P: 1
I have written a very simple program to create an instance in Python. my code is as follows.

Expand|Select|Wrap|Line Numbers
  1. class Athlets:
  2.       def _init_(self,a_name):
  4. sarah = Athlets("Sarah")
  5. print(sarah)

But I am getting TypeError like bellow
Traceback (most recent call last):
File "", line 4, in <module>
sarah = Athlets("Sarah")
TypeError: this constructor takes no arguments

please help
Jul 6 '11 #1
Share this Question
Share on Google+
1 Reply

P: 55
Name of the constructor should be __init__ (with two underscore characters on either side). A small typo, The rest is good.
Jul 6 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.