Which of the following correctly implements a Singleton pattern in Python using a metaclass?

Python Professional Hard

Python Professional — Hard

Which of the following correctly implements a Singleton pattern in Python using a metaclass?

Key points

  • Metaclasses are used to control the creation of classes and instances
  • `__new__` is responsible for creating instances
  • Singleton pattern ensures only one instance of a class exists
  • Using `__init__` or `@staticmethod` won't guarantee a single instance

Ready to go further?

Related questions