#!/usr/bin/python
class Klasa(object):
pass
class Singletone(object):
__instance = None
def __new__(self):
if Singletone.__instance == None:
Singletone.__instance = self
return Singletone.__instance
if __name__ == '__main__':
s1 = Singletone()
s2 = Singletone()
k1 = Klasa()
k2 = Klasa()
print 'Singletone: ' + repr(s1 is s2)
print 'Klasa: ' + repr(k1 is k2)
Python coraz bardziej mi się podoba :)
No comments:
Post a Comment