Skip to main content
2 of 7
edited title
langlauf.io
  • 261
  • 1
  • 2
  • 6

Python classes with only one instance: When to create a (single) class instance and when to work with the class instead?

Given a python class which will be instantiated only once, i.e. there will be only one object of the class. I was wondering in which cases it makes sense to create a single class instance instead of working directly with the class instead.

There is a similar thread, but it has a different focus: (1) it is about grouping global variables and functions into a class and (2) it is not python-specific. The latter means it does not consider the fact that (in python) classes are objects too.

langlauf.io
  • 261
  • 1
  • 2
  • 6