return singleton __instance def __init__(self)""virtually private constructor ""if singleton __instance !noneraise exception("this class is singleton!"elsesingleton __instance self singleton(print singleton getinstance(print singleton getinstance(print output the above program generates the following output