コード例 #1
0
def main():
    print('Start.')
    obj1 = Singleton()
    obj2 = Singleton()

    if (obj1 == obj2):
        print('obj1 and obj2 are the same instance')

    else:
        print('obj1 and obj2 are not the same instance')

    print('End.')
コード例 #2
0
    def sort_column_checkbox_table_widget_stock_screener(column):
        """
        Sorted column with checkbox, ascending = Unchecked to Checked ; descending = Checked to Unchecked
        :param column: column of header cell clicked
        :type column: int
        :return: None
        """
        table_widget = ui.tableWidget_stockScreener

        # When a click is made on a column's name, a sorting is done. We are changing the indicator in MainWindow
        # accordingly. The ValueTableItems that we are using use that indicator to adjust their comparison's algorithms.
        if table_widget.horizontalHeader().sortIndicatorOrder() == 0:
            Singleton.set_order(Singleton(), True)
        else:
            Singleton.set_order(Singleton(), False)

        if column == table_widget.columnCount() - 1:
            HelperFunctionQt.sorted_column_checkbox_table_widget(table_widget)
コード例 #3
0
os.chdir(os.path.dirname(os.path.abspath(__file__)))

from constants import *

try:
    PYPROPS_CORELIBPATH
    sys.path.append(PYPROPS_CORELIBPATH)
except NameError:
    pass

from PiRelayApp import PiRelayApp
from Singleton import Singleton, SingletonException

me = None
try:
    me = Singleton()
except SingletonException:
    sys.exit(-1)
except BaseException as e:
    print(e)

if USE_GPIO and os.path.isfile('/opt/vc/include/bcm_host.h'):
    import RPi.GPIO as GPIO
    GPIO.setmode(GPIO.BCM)
    if GPIO_CLEANUP:
        # GPIO.cleanup() sets any GPIO you have used within RPi.GPIO to INPUT mode.
        # If that behaviour is desirable call the method before exiting your script.
        GPIO.cleanup()
    else:
        GPIO.setwarnings(False)
コード例 #4
0
__author__ = 'yokoi-h'

from Singleton import Singleton
from Singleton2 import INSTANCE

if __name__ == "__main__":
    ins1 = Singleton.getInstance()
    ins2 = Singleton.getInstance()
    print ins1.name
    print ins2.name
    if ins1 is ins2:
        print "same"
    else:
        print "different"

    ins3 = Singleton("hoge")
    if ins1 is ins3:
        print "same"
    else:
        print "different"

    ins4 = INSTANCE
    ins5 = INSTANCE
    print ins4.name
    print ins5.name
    if ins4 is ins5:
        print "same"
    else:
        print "different"
コード例 #5
0
ファイル: Main.py プロジェクト: Om4ar/Design-Patterns
from Singleton import Singleton

if __name__ == "__main__":
    
    singleton = Singleton()
    singletonTwo = Singleton()

    singleton.setNumber(5)

    print("Singleton:")
    print("Number: ", singleton.getNumber())


    print("Singleton Two:")
    print("Number: ", singletonTwo.getNumber())

    singleton.setNumber(99)

    print("Singleton:")
    print("Number: ", singleton.getNumber())


    print("Singleton Two:")
    print("Number: ", singletonTwo.getNumber())

    print("Singleton:")
    print(singleton)

    print("Singleton Two:")
    print(singletonTwo)
コード例 #6
0
from Singleton import Singleton


first_singleton = Singleton()
first_singleton.talk()
first_singleton.name()

second_singleton = Singleton()
second_singleton.talk()
second_singleton.name()
コード例 #7
0
ファイル: main.py プロジェクト: dl57934/hoony_blog_Data
def main():
    a = Singleton()
    b = Singleton()

    if (a == b):
        print("같다")
コード例 #8
0
from Singleton import Singleton

Class1 = Singleton('Hello Hady')
Class2 = Singleton('Hello Hady 2')

print(Class1 is Class2)
コード例 #9
0
if __name__ == "__main__":
    from Singleton import Singleton
else:
    from .Singleton import Singleton


class ConcreteClass(Singleton):
    pass


#print(Singleton())
#print(ConcreteClass())

print(ConcreteClass())
print(Singleton())