473,218 Members | 1,423 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,218 software developers and data experts.

this constructor takes no arguments (defining class)

Expand|Select|Wrap|Line Numbers
  1. class double:
  2.         def __ini__(self,x1,y2):
  3.                 self._x=x1
  4.                 self._y=y2
  5.  
  6.         def result(self):
  7.                 return (self._x)*(self._y)
  8.  
  9.         def x2(self):
  10.                 return 2*self._result()
  11.  
  12. >>> a=double(10,1)
  13. Traceback (most recent call last):
  14.   File "<pyshell#7>", line 1, in <module>
  15.     a=double(10,1)
  16. TypeError: this constructor takes no arguments
  17.  
what's wrong in my code?
Oct 7 '07 #1
1 8875
elcron
43
Expand|Select|Wrap|Line Numbers
  1. class double:
  2.         def __ini__(self,x1,y2):
  3.                 self._x=x1
  4.                 self._y=y2
  5.  
  6.         def result(self):
  7.                 return (self._x)*(self._y)
  8.  
  9.         def x2(self):
  10.                 return 2*self._result()
  11.  
  12. >>> a=double(10,1)
  13. Traceback (most recent call last):
  14.   File "<pyshell#7>", line 1, in <module>
  15.     a=double(10,1)
  16. TypeError: this constructor takes no arguments
  17.  
what's wrong in my code?
Expand|Select|Wrap|Line Numbers
  1. class double:
  2.         def __init__(self,x1,y2):
  3.                 self._x=x1
  4.                 self._y=y2
  5.  
  6.         def result(self):
  7.                 return (self._x)*(self._y)
  8.  
  9.         def x2(self):
  10.                 return 2*self._result()
  11.  
__init__ is the constructor for a class. You left out the t
Oct 7 '07 #2

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

Similar topics

2
by: Sergey Krushinsky | last post by:
Hello all, Is there a common way to emulate constructor overloading in Python class? For instanse, I have 3 classes: 1/ Polar - to hold polar coordinates; 2/ Cartesian - to hold cartesian...
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: Vasileios | last post by:
Hello everyone, I have a very simple question. Imagine that I have a CBase class with a nondefault constructor that takes one argument CBase::CBase(int A) And a derived class CDerived that...
4
by: N3TB1N | last post by:
Here is my assignment. I am hoping that someone here quickly knows all of the correct answers... especially for question #5 and everything after. Thanks in advance. ...
34
by: Jason Heyes | last post by:
Is there a special name for a constructor that does struct-like initialisation? Example: class DefaultCtor { std::string class_name; bool compiler_generated; public:...
9
by: Player | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello all. I am in the process of teaching myself C# and I think I am doing OK. I have learnt how to how to call the right constructor of a...
6
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of...
12
by: Edward Diener | last post by:
Given value class X { public: // Not allowed: X():i(100000),s(10000) { } // Allowed void InitializeDefaults() { i = 100000; s = 10000; } private: int i;
7
by: Ron | last post by:
I have a couple of questions about this class.....: Public Class WordPair Private word1 As String Private word2 As String Public Sub New() word1 = "" word2 = "" End Sub Public Sub New(ByVal...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.