J
jnair
My Tead Lead my object counter code seen below is not pythonic
class E(object):
_count = 0
def __init__(self):
E._count += 1
count = property(lambda self: E._count )
def test():
if __name__ == "__main__":
e1 = E()
print e1.count
e2 = E()
print e2.count
e3 = E()
print e3.count
test()
if not waht woutld be the pythonic way
class E(object):
_count = 0
def __init__(self):
E._count += 1
count = property(lambda self: E._count )
def test():
if __name__ == "__main__":
e1 = E()
print e1.count
e2 = E()
print e2.count
e3 = E()
print e3.count
test()
if not waht woutld be the pythonic way