Demo entry 6625728

python example

   

Submitted by anonymous on Jun 22, 2017 at 01:27
Language: Python 3. Code size: 294 Bytes.

# Singleton/ClassVariableSingleton.py
class SingleTone(object):
    __instance = None
    def __new__(cls, val):
        if SingleTone.__instance is None:
            SingleTone.__instance = object.__new__(cls)
        SingleTone.__instance.val = val
        return SingleTone.__instance

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).