Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A problem with child class
#3
The speed in the run method is not an attribute of the class, it is a parameter to the method. You would only use self-dot for an attribute, like name. speed you would just reference by itself, like a parameter to a function. This should work:

def run(self, speed):
        return f'{self.name} runs {speed}'
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
A problem with child class - by Truman - Jul-01-2018, 11:22 PM
RE: A problem with child class - by gontajones - Jul-02-2018, 12:35 AM
RE: A problem with child class - by ichabod801 - Jul-02-2018, 12:37 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  class definition and problem with a method HerrAyas 2 265 Apr-01-2024, 03:34 PM
Last Post: HerrAyas
Question __init__ of Child Class zero_fX0 4 1,732 Mar-22-2023, 05:23 PM
Last Post: deanhystad
  Using one child class method in another child class garynewport 5 1,606 Jan-11-2023, 06:07 PM
Last Post: garynewport
  Child class inheritance issue eakanathan 3 1,344 Apr-21-2022, 12:03 PM
Last Post: deanhystad
  Can we access instance variable of parent class in child class using inheritance akdube 3 14,004 Nov-13-2020, 03:43 AM
Last Post: SalsaBeanDip
  Practice problem using lambda inside the class jagasrik 3 2,176 Sep-12-2020, 03:18 PM
Last Post: deanhystad
  calling on a method from one class into another class which is not a child NABA 5 2,826 Apr-29-2020, 07:49 PM
Last Post: deanhystad
  [split] Python Class Problem astral_travel 12 5,015 Apr-29-2020, 07:13 PM
Last Post: michael1789
  Python Class Problem JPCrosby 2 2,306 Apr-28-2020, 06:18 PM
Last Post: buran
  Class problem duckduck23 2 2,032 Feb-10-2020, 08:52 PM
Last Post: jefsummers

Forum Jump:

User Panel Messages

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