Code AnalysisHard 45s
__new__ singleton
What is the output?
Starter code
class S:
_inst = None
def __new__(cls):
if cls._inst is None:
cls._inst = super().__new__(cls)
return cls._inst
a = S()
b = S()
print(a is b)Think you can answer under pressure?
Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.