Python Forum
TypeError: method missing 1 positional argument
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TypeError: method missing 1 positional argument
#2
Please use python and output tags when posting code and results. I put them in for you this time. Here are instructions for doing it yourself next time.

Look at your definition of Pet, specifically the get_name method. You defined two parameters: self and name. The self parameter is provided automatically for instances of the class, but you have to provide name. If you don't, the function fails. You don't use the name parameter, so you should probably just remove it. You're going to have the same problem with your other getters.

BTW, this is Python, not Java. You never almost never use getters and setters in Python. They slow things down, make your code harder to understand, and don't actually do anything. If you really need that sort of security (as in, self.y must change whenever self.x changes) you use properties. But generally you just don't bother.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: TypeError: method missing 1 positional argument - by ichabod801 - Nov-14-2018, 03:36 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  TypeError: __init__() missing 1 required positional argument: 'successor siki 1 4,454 Mar-08-2021, 02:05 PM
Last Post: Larz60+
  Missing 1 required positional argument in python code edwinostby 7 10,382 Jan-19-2021, 12:52 PM
Last Post: Serafim
  Missing positional arguments error?? hhydration 2 2,246 Oct-01-2020, 05:33 AM
Last Post: buran
  TypeError: Missing required positional arguments liaisa 7 29,881 Sep-25-2020, 08:16 PM
Last Post: deanhystad
  missing positional argument error programmert 1 2,911 Oct-18-2019, 11:05 AM
Last Post: Larz60+
  missing 1 required positional argument jedmond2 4 7,013 Sep-19-2019, 12:00 PM
Last Post: jefsummers
  missing 1 required positional argument mcgrim 10 20,149 May-07-2019, 09:02 PM
Last Post: Yoriz
  TypeError: __init__() missing 3 required positional arguments Pythonhelp82 6 23,489 Jan-24-2019, 04:25 AM
Last Post: Pythonhelp82
  another positional argument error (...and executing objects stored in a list) itmustbebunnies 7 4,412 Nov-16-2018, 07:18 PM
Last Post: itmustbebunnies
  Class positional argument error itmustbebunnies 2 3,099 Nov-07-2018, 11:09 AM
Last Post: stullis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020