pablobuenaposada / HonDash

Dashboard for Hondata K-Pro & S300 ECUs
GNU Affero General Public License v3.0
66 stars 29 forks source link

refactor backend.py #110

Closed pablobuenaposada closed 4 years ago

pablobuenaposada commented 4 years ago

from random import randint class Foobar: _singleton = None

def __init__(self):
    self.rand = randint(0, 100)
    self.name = 'hello'

@classmethod
def get_or_create(cls):
    if cls._singleton is None:
        cls._singleton = cls()
    return cls._singleton

def my_method1(self):
    print(f'{self.name} {self.rand}')

@classmethod
def my_cls_method1(cls):
    cls.get_or_create().my_method1()

websocket

def my_method1():

Foobar.my_cls_method1()

foobar = Foobar()
foobar.my_method1()

my_method1() my_method1() my_method1() my_method1()

pablobuenaposada commented 4 years ago

done here 8dde8f4a3641616276713fab7229197222a4a2ac