Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python classes
#3
Hi deanhystad

Is inheritance the only way to achieve this?
I do not want to implement this via inheritance, because the 2 classes may not always be related.
Let me explain. I'm trying to write a simple table driven agent program (vacuum cleaner cleaning 2 rooms - the classic AI example). In this program the vacuum cleaner must set the room status to "clean" after cleaning it.
Thus, the vacuum object must call the room object's room.set_status('c').

In this scenario a room and a vacuum is not the same type of object and thus implementing inheritance between the room and vacuum classes does not make sense, not so?

Is there no other way to achieve this goal?
Reply


Messages In This Thread
Python classes - by PythonNewbee - Nov-08-2022, 02:00 PM
RE: Python classes - by deanhystad - Nov-08-2022, 03:02 PM
RE: Python classes - by PythonNewbee - Nov-09-2022, 10:27 AM
RE: Python classes - by DeaD_EyE - Nov-09-2022, 01:18 PM
RE: Python classes - by deanhystad - Nov-09-2022, 01:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python inner classes inheritance from parent class Abedin 8 998 Apr-23-2025, 05:56 AM
Last Post: Gribouillis
  Python Classes rob101 4 1,602 Feb-05-2024, 06:51 PM
Last Post: rob101
  Understanding Python classes PythonNewbee 3 2,221 Nov-10-2022, 11:07 PM
Last Post: deanhystad
  Inheritance vs Instantiation for Python classes mr_byte31 7 5,581 Oct-14-2021, 12:58 PM
Last Post: mr_byte31
  Understanding Python super() for classes OmegaRed94 1 2,481 Jun-09-2021, 09:02 AM
Last Post: buran
  Python classes Python_User 15 8,676 Aug-04-2020, 06:57 PM
Last Post: Python_User
  Python Classes leodavinci1990 1 2,690 Nov-27-2019, 07:25 AM
Last Post: buran
  Using classes? Can I just use classes to structure code? muteboy 5 6,465 Nov-01-2017, 04:20 PM
Last Post: metulburr
  Python Classes or Functions for large scale application ? Vithulan 5 5,832 Oct-23-2017, 04:48 PM
Last Post: Larz60+
  use of classes in python Lux 2 4,273 Aug-19-2017, 12:29 PM
Last Post: hbknjr

Forum Jump:

User Panel Messages

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