The Real Python Podcast cover image

Preparing for an Interview With Python Practice Problems

The Real Python Podcast

00:00

How to Use Dunder New to Create a Singleton Class

Dunder New is used to create a singleton class so that every time you instantiate it you get the exact same object back in memory. Brandon Rhodes has this Python dash pattern site guide website which is a fantastic website to learn about design patterns and everything like this. He doesn't really give an example of why you would want to use Dunder New but he recommends the alternative of the global object pattern. That is actually the way a lot of things are done in the standard library rather than using Dunder New for instance.

Transcript
Play full episode

The AI-powered Podcast Player

Save insights by tapping your headphones, chat with episodes, discover the best highlights - and more!
App store bannerPlay store banner
Get the app