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

  • SEARCH
  • Home
  • 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 74737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:24:19+00:00 2026-05-10T20:24:19+00:00

WARNING: I have been learning Python for all of 10 minutes so apologies for

  • 0

WARNING: I have been learning Python for all of 10 minutes so apologies for any stupid questions!

I have written the following code, however I get the following exception:

Message File Name Line Position Traceback Node 31 exceptions.TypeError: this constructor takes no arguments

class Computer:      name = 'Computer1'     ip = '0.0.0.0'     screenSize = 17       def Computer(compName, compIp, compScreenSize):         name = compName         ip = compIp         screenSize = compScreenSize          printStats()          return      def Computer():         printStats()          return      def printStats():         print 'Computer Statistics: --------------------------------'         print 'Name:' + name         print 'IP:' + ip         print 'ScreenSize:' , screenSize // cannot concatenate 'str' and 'tuple' objects         print '-----------------------------------------------------'         return  comp1 = Computer() comp2 = Computer('The best computer in the world', '27.1.0.128',22) 

Any thoughts?

  • 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. 2026-05-10T20:24:19+00:00Added an answer on May 10, 2026 at 8:24 pm

    I’m going to assume you’re coming from a Java-ish background, so there are a few key differences to point out.

    class Computer(object):     '''Docstrings are used kind of like Javadoc to document classes and     members.  They are the first thing inside a class or method.      You probably want to extend object, to make it a 'new-style' class.     There are reasons for this that are a bit complex to explain.'''      # everything down here is a static variable, unlike in Java or C# where     # declarations here are for what members a class has.  All instance     # variables in Python are dynamic, unless you specifically tell Python     # otherwise.     defaultName = 'belinda'     defaultRes = (1024, 768)     defaultIP = '192.168.5.307'      def __init__(self, name=defaultName, resolution=defaultRes, ip=defaultIP):         '''Constructors in Python are called __init__.  Methods with names         like __something__ often have special significance to the Python         interpreter.          The first argument to any class method is a reference to the current         object, called 'self' by convention.          You can use default function arguments instead of function         overloading.'''         self.name = name         self.resolution = resolution         self.ip = ip         # and so on      def printStats(self):         '''You could instead use a __str__(self, ...) function to return this         string.  Then you could simply do 'print(str(computer))' if you wanted         to.'''         print 'Computer Statistics: --------------------------------'         print 'Name:' + self.name         print 'IP:' + self.ip         print 'ScreenSize:' , self.resolution //cannot concatenate 'str' and 'tuple' objects         print '-----------------------------------------------------' 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code, for which I get the error: Warning : mysqli_stmt::bind_result()
I have been searching for 10 minutes why the first line gets a warning
I have a function that gives me the following warning: [DCC Warning] filename.pas(6939): W1035
I have been reading a lot about Reinforcement Learning lately, and I have found
I've been learning about gems lately, and one error I get is: WARNING: Installing
I am a newcomer to Silverlight and while I have been following some tutorials
I have been following the documentation for using NSURLConnection and am using delegates for
I have been battling with this code for quite a while and just don't
I have been following the simple guide at http://www.atinfinity.info/wiki/index.php?OpenCV/Using%20OpenCV%202.2%20on%20iOS%20SDK%204.2 (which uses the older guide
We have been working on a project for several months without any problems until

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.