예제 #1
0
def main():
    s = Singleton()
    print s

    s = Singleton.get_instance()
    print s

    s = Singleton.get_instance()
    print s
예제 #2
0
    def operacion(self):
        print("Ejemplo Singleton")
        x = Singleton.get_instance()
        y = Singleton.get_instance()

        print(x is y)

        y.set_value(10)

        print(x.get_value())
예제 #3
0
    def set_operacion(self):
        print("Ejmeplo con Singleton")
        x = Singleton.get_instance()
        y = Singleton.get_instance()

        print(x is y)

        y.set_value(10)

        print(x.get_value())

        print(y.get_value())

        print(x is y)
예제 #4
0
파일: main.py 프로젝트: ke2ek/DesignPattern
def main():
    singleton = Singleton()
    print('Address =', hex(id(singleton)))
    instance = Singleton.get_instance()
    print('Address =', hex(id(instance)))
예제 #5
0
from singleton import Singleton

if __name__ == "__main__":
    s1 = Singleton.get_instance()
    s1.message_1()
    s1.message_2()
    print(s1)

    s2 = Singleton.get_instance()
    s2.message_1()
    s2.message_2()
    print(s2)
예제 #6
0
def test_pipe(pipe, i):
    s = Singleton.get_instance()
    pipe.send(s)
    print "This is process", i, s
예제 #7
0
def test():
    s = Singleton.get_instance()
    print s
    instances.add(s)
예제 #8
0
# singleton client

from singleton import Singleton

if __name__ == '__main__':
    inst = Singleton()
    print(inst)

    inst = Singleton.get_instance()
    print(inst)
예제 #9
0
    def test_singleton(self):
        instance_a = Singleton.get_instance()
        instance_b = Singleton.get_instance()

        self.assertEqual(instance_a, instance_b)