Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3601434
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:37:17+00:00 2026-05-18T20:37:17+00:00

What is the error below? Also, is there a better way to implement the

  • 0

What is the error below? Also, is there a better way to implement the following classes?

     #!/usr/bin/python

     class Datacenters:
        def __init__(self,name,location,cpu,mem):
           self.name=name
           self.location=location
           self.cpu=cpu
           self.mem=mem

        def  getparam(self):
           return self.name,self.location ,self.cpu,self.mem

        def  getname(self):
           return self.name

     class WS(Datacenters):
        def __init__(self,name,location,cpu,mem,obj):
           #datacentername = Datacenters.__init__(self) #To which data center it is associated
           self.dcname =obj.name #To which data center it is associated

           Datacenters.__init__(obj,name,location,cpu,mem)

        def getparam(self,obj):
           self.name,self.location ,self.cpu,self.mem = obj.getparam()
           print self.dcname
           #return self.name,self.location ,self.cpu,self.mem,obj.name

        def  getwsname(self):
           return self.name

     class Pcs(WS):
        def __init__(self,name,location,cpu,mem,obj):
           self.wsname = obj.getwsname() #To which WS it is  associated
           WS.__init__(obj,name,location,cpu,mem)

        def  getparam(self,obj):
           print obj.getparam()
           print self.wsname


     a = Datacenters("dc1","Bl1",20,30)
     print a.getparam()
     b = WS("WS1","Bl1",21,31,a)
     print b.getparam(a)
     c = Pcs("PC1","Bl1",20,30,b)
     #print c.getparam(b)

output:

   Press ENTER or type command to continue 
   ('dc1', 'Bl1', 20, 30)
   dc1
   None
   Traceback (most recent call last):
   File "class1.py", line 45, in <module>
   c = Pcs("PC1","Bl1",20,30,b)
   File "class1.py", line 34, in __init__
   WS.__init__(obj,name,location,cpu,mem)
   TypeError: __init__() takes exactly 6 arguments (5 given)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T20:37:18+00:00Added an answer on May 18, 2026 at 8:37 pm

    The error is that you pass in five arguments, but the __init__ needs six. Count them:

    def __init__(self,name,location,cpu,mem,obj):
    

    Six arguments. You call it like so:

    WS.__init__(obj,name,location,cpu,mem)
    

    Five arguments. The first one, self is missing. What you should ask yourself is why you don’t have to pass in six arguments all the time.

    And that is because self is passed in automatically when you call the method on an instance. However, in this case you don’t call it on an instance, you call it directly on the class. There is of course no need to do so in this case, the correct syntax is:

    WS(obj,name,location,cpu,mem)
    

    As you indeed above note works further up.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the error below? Also, is there a better way to implement the
Why does the following query raise the error below for a row with a
In my current project I'm using classes which implement the following ITransaction interface shown
This below codes give me error below: How to generate this codes help me
Anyone familiar with error below? When I run my webapp to generate a dynamic
I am getting the error below when I call my WCF service. What am
We are getting the error below calling c:\windows\syswow64\regsvr32.exe on Windows Server 2008 R2 x64.
I'm getting the error below for this SQL statement in VB.Net 'Fill in the
I will get the error below randomly when I'm running an asp.net application I
I'm trying to build a java application with gcj but getting the error below.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.