{"action":"created","issue":{"url":"https://api.github.com/repos/faif/python-patterns/issues/163","repository_url":"https://api.github.com/repos/faif/python-patterns","labels_url":"https://api.github.com/repos/faif/python-patterns/issues/163/labels{/name}","comments_url":"https://api.github.com/repos/faif/python-patterns/issues/163/comments","events_url":"https://api.github.com/repos/faif/python-patterns/issues/163/events","html_url":"https://github.com/faif/python-patterns/issues/163","id":187881089,"number":163,"title":"Singleton Pattern","user":{"login":"supritashankar","id":1830172,"avatar_url":"https://avatars.githubusercontent.com/u/1830172?v=3","gravatar_id":"","url":"https://api.github.com/users/supritashankar","html_url":"https://github.com/supritashankar","followers_url":"https://api.github.com/users/supritashankar/followers","following_url":"https://api.github.com/users/supritashankar/following{/other_user}","gists_url":"https://api.github.com/users/supritashankar/gists{/gist_id}","starred_url":"https://api.github.com/users/supritashankar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/supritashankar/subscriptions","organizations_url":"https://api.github.com/users/supritashankar/orgs","repos_url":"https://api.github.com/users/supritashankar/repos","events_url":"https://api.github.com/users/supritashankar/events{/privacy}","received_events_url":"https://api.github.com/users/supritashankar/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-08T01:53:15Z","updated_at":"2016-11-08T12:26:09Z","closed_at":null,"body":"I want to create a simple singleton pattern. \r\n\r\nWhose code looks something like this.\r\n\r\n    class Singleton(object):\r\n      _instance = None\r\n      def __new__(self):\r\n        if not self._instance:\r\n          self._instance = super(Singleton, self).__new__(self)\r\n          self.num = 10\r\n        return self._instance\r\n\r\n    x = Singleton()\r\n    print x.num #10\r\n    x.num = 20\r\n    z = MyClass()\r\n    print z.num #20 \r\n\r\nI understand that `Borg` has a singleton class too. But this I felt is a much simpler example. \r\nIf you guys give 👍  I will go ahead and send a PR\r\n\r\ncc @faif "},"comment":{"url":"https://api.github.com/repos/faif/python-patterns/issues/comments/259123640","html_url":"https://github.com/faif/python-patterns/issues/163#issuecomment-259123640","issue_url":"https://api.github.com/repos/faif/python-patterns/issues/163","id":259123640,"user":{"login":"fkromer","id":10199742,"avatar_url":"https://avatars.githubusercontent.com/u/10199742?v=3","gravatar_id":"","url":"https://api.github.com/users/fkromer","html_url":"https://github.com/fkromer","followers_url":"https://api.github.com/users/fkromer/followers","following_url":"https://api.github.com/users/fkromer/following{/other_user}","gists_url":"https://api.github.com/users/fkromer/gists{/gist_id}","starred_url":"https://api.github.com/users/fkromer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fkromer/subscriptions","organizations_url":"https://api.github.com/users/fkromer/orgs","repos_url":"https://api.github.com/users/fkromer/repos","events_url":"https://api.github.com/users/fkromer/events{/privacy}","received_events_url":"https://api.github.com/users/fkromer/received_events","type":"User","site_admin":false},"created_at":"2016-11-08T12:26:09Z","updated_at":"2016-11-08T12:26:09Z","body":"Hi @supritashankar, one could consider [some book examples about different singleton variants and implementations](https://github.com/python-pattern-language/python-pattern-references/blob/master/design_patterns/singleton_pattern.rst)."}}
{"actor":{"display_login":"fkromer"}}