Python Forum
Classes in general description
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Classes in general description
#2
I don't think you understand class and instance. A class is a description or definition of a thing. An instance is the thing. So a Machine is both a class and and instance. The class Machine describes how the machine works and how it is constructed, but it is not a machine that can do things. To have a machine that can do thing you need to create an instance of the Machine class.

Things like length and color and the like are attributes. If they are the same for every machine they are class attributes. If they are different for different machines they are instance attributes.

Physical or not physical had nothing to do with class/instance. You can make classes that describe non-physical things like processes and procedures and operations, and then make instances of these that can execute the process or implement the procedure. To stay with you Machine analogy you could have a CNC Program class that knows how to read a CMC program and send commands to the machine. It is quite common for such a thing to be implemented as a class, and to make an instance of this class that is part of your machine controller.
Reply


Messages In This Thread
Classes in general description - by Python_User - Aug-30-2020, 03:24 PM
RE: Classes in general description - by deanhystad - Aug-30-2020, 03:59 PM
RE: Classes in general description - by Python_User - Sep-01-2020, 05:30 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Get file description Raysz 2 567 Nov-25-2023, 03:46 PM
Last Post: Raysz
  Why is the 'meta description' html tag not translated? Melcu54 2 994 Oct-15-2022, 10:55 PM
Last Post: Larz60+
  What should i do, for this code to work -> description hamad 2 1,484 Nov-18-2021, 01:22 PM
Last Post: ghoul
  Using classes? Can I just use classes to structure code? muteboy 5 5,113 Nov-01-2017, 04:20 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

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