Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Singleton example #226

Closed
GeorgiosGoniotakis opened this issue Jun 7, 2018 · 2 comments
Closed

Singleton example #226

GeorgiosGoniotakis opened this issue Jun 7, 2018 · 2 comments
Labels

Comments

@GeorgiosGoniotakis
Copy link

@GeorgiosGoniotakis GeorgiosGoniotakis commented Jun 7, 2018

Hello there. I noticed that there is no example of the Singleton design pattern. However, I saw an example of Borg https://github.com/faif/python-patterns/blob/master/creational/borg.py I was thinking of adding that. Any thoughts?

@fkromer
Copy link
Contributor

@fkromer fkromer commented Jun 7, 2018

I collected some references to implementation variants of the singleton pattern in Python some while ago: python-pattern-reference - singleton pattern. In the meanwhile new books came out which could come with new, different implementations (I am quite sure about it but I had no time to look into it in detail so far).

@faif
Copy link
Owner

@faif faif commented Jun 8, 2018

@GeorgiosGoniotakis In Python there two recommended ways of implementing a singleton:

  • Use a module (by definition can only be imported onced)
  • Use borg

Since those singleton implementations are considered more of an antipattern I've resisted adding them

@faif faif added the question label Jun 8, 2018
@faif faif closed this Jun 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.