473,382 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

ypeError: this constructor takes no arguments

Hello
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):
  3.           self.name=a_name
  4. sarah = Athlets("Sarah")
  5. print(sarah)

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

please help
thanks
Jul 6 '11 #1
1 2938
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

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

Similar topics

4
by: Manoj | last post by:
Hi , I have written a simple program usinga class. But it not compiling.The error i get is my = myclass("Paul", "John") TypeError: this constructor takes no arguments I checked some previous...
2
by: ishekar | last post by:
Hi, I have a class which has only one constructor that takes an argument. I want the users of this class to pass the parameter in the declaration. The problem i am facing is this cannot be used...
7
by: b83503104 | last post by:
Previously, when my constructor had no arguments, I used this to declare my objects: MyClass myObject; Now, my constructor has arguments (MyClass::MyClass(int someVariable)), how do I declare...
26
by: Martin Jørgensen | last post by:
Hi, I'm learning C-programming. I have a program which I would like to modify so it takes arguments from the commandline. Let call the program: program.exe. Could somebody shortly explain how...
1
by: python101 | last post by:
class double: def __ini__(self,x1,y2): self._x=x1 self._y=y2 def result(self): return (self._x)*(self._y) def...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.