Singleton Design Pattern - Advanced Python Tutorial #9

preview_player
Показать описание
In this video we talk about the singleton design pattern in Python.

◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾◾
📚 Programming Books & Merch 📚

💻 Exclusive Content 💻

🌐 Social Media & Contact 🌐

Рекомендации по теме
Комментарии
Автор

A Singleton pattern in python is a design pattern that allows you to create just one instance of a class, throughout the lifetime of a program. Using a singleton pattern has many benefits. A few of them are: To limit concurrent access to a shared resource.

xzex
Автор

Just what I needed, thank you so much!

brnwiqz
Автор

I swear I learn more from you than from college

HerptieDerper
Автор

great video, i'm actually learning a from the *design pattern* videos

WordsThroughTheSky
Автор

thank you floren. need more video on the rest of the common design pattern.

yonatanbeyn
Автор

I was missing the explanation, on why you would do this? What are the applications? And why always use person as an example, which doesn't say anything. Couldn't you have used a more applied example? Other than that, I love your videos! Please keep up the good work!

DominatorIII
Автор

Can we make this pattern look more "pythonic" by overriding the __new__ static method instead of introducing get_instance?

FILALIHOUCEMEDDINE
Автор

imagine being a complete python noob and watching this..

SparePlayss
Автор

Python programmers almost never implement the Singleton Pattern as described in the Gang of Four book, whose Singleton class forbids normal instantiation and instead offers a class method that returns the singleton instance. Python is more elegant, and lets a class continue to support the normal syntax for instantiation while defining a custom __new__() method that returns the singleton instance. But an even more Pythonic approach, if your design forces you to offer global access to a singleton object, is to use The Global Object Pattern instead.

xzex
Автор

3:09 Never use sth == None. pep8 does not recommend that. Instead, use sth is None.

mienislav
Автор

Why do you need to create an interface for this singleton example??🤔🤔

sayaknaiya
Автор

Hi bro . Help me I can't understand about this pattern topic can you explain pls? And how many types are there?

nirmaltheprogrammer
Автор

Why do we need, or do we need the IPerson class at all?

kdbwiz
Автор

implementation using decorator

def singleton(cls):
instances = {}
def getinstance():
if cls not in instances:
instances[cls] = cls()
return instances[cls]
return getinstance

@singleton
class MyClass:
...

pkzkkog
Автор

Why creating get_instance method if you don't use it ?

guy
Автор

Can we inherit from this singleton class?

gavin
Автор

I think you should add thread lock. So it will make it thread safe

tusharkuwar
Автор

This is an overly-complex solution. Don't need any abstractions or classes. All you need is a global variable + 1 function.

Feels like you're writing Java in Python my dude.

SergioInToronto
Автор

Great explanation! I'm still trying to figure out where this pattern can be used. Anyway. Thanks!

jrgomez
Автор

Hey! A very clear explanation as usual. A suggestion, you could display your video on the bottom left, that way it won't block any text.

MrWadood