Python Forum
writing a class or a function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
writing a class or a function
#6
There are no cases where classes are required.

Python is a great example, being written in C, which itself doesn't support classes. It then follows, that anything in python is also possible in C, and that anything you could accomplish with a class, you could also accomplish without one.

So no, there are no cases where a class is essential over a function.

That said, they were created for a reason, and that reason is state management. If you have state you're keeping track of, classes help encapsulate that state, as well as grouping related functions together to strongly indicate to other readers that the functions are, in fact, related to one another.
Reply


Messages In This Thread
writing a class or a function - by Skaperen - Dec-28-2018, 06:59 AM
RE: writing a class or a function - by Gribouillis - Dec-28-2018, 07:40 AM
RE: writing a class or a function - by Larz60+ - Dec-28-2018, 10:21 AM
RE: writing a class or a function - by ichabod801 - Dec-28-2018, 03:04 PM
RE: writing a class or a function - by Skaperen - Dec-28-2018, 07:18 PM
RE: writing a class or a function - by nilamo - Dec-28-2018, 08:00 PM
RE: writing a class or a function - by Skaperen - Dec-30-2018, 04:30 AM
RE: writing a class or a function - by ichabod801 - Dec-28-2018, 08:56 PM
RE: writing a class or a function - by Gribouillis - Dec-28-2018, 09:01 PM
RE: writing a class or a function - by Larz60+ - Dec-29-2018, 12:26 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  extracting a function/class/method from code Skaperen 5 2,331 Mar-30-2022, 12:13 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

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