Re: Is this object counter code pythonic

2006-04-11 Thread bruno at modulix
[EMAIL PROTECTED] wrote: > Fredrik is then this a valid "property" use case and pythonic to > get/set a common varibale across objects > > class E(object): > _i = 0 > def geti(self) : return E._i > def seti(self,val) : E._i = val > i = property(geti,seti) > > if __name__ == "_

Re: Is this object counter code pythonic

2006-04-10 Thread Duncan Booth
[EMAIL PROTECTED] wrote: > Fredrik is then this a valid "property" use case and pythonic to > get/set a common varibale across objects A valid poperty use case would be one where you did something that couldn't be done without using a property. In some other languages you cannot simply chan

Re: Is this object counter code pythonic

2006-04-10 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: > Fredrik is then this a valid "property" use case and pythonic to > get/set a common varibale across objects No. you do that only if you have some kind of behavior attached - e.g. if there are database queries to be made for returning a property or something like tha

Re: Is this object counter code pythonic

2006-04-10 Thread jnair
Fredrik is then this a valid "property" use case and pythonic to get/set a common varibale across objects class E(object): _i = 0 def geti(self) : return E._i def seti(self,val) : E._i = val i = property(geti,seti) if __name__ == "__main__": e1 = E() e1.i = 100

Re: Is this object counter code pythonic

2006-04-10 Thread jnair
Ok got it . Thanks a Lot -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this object counter code pythonic

2006-04-10 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > My Team Lead says 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() >

Is this object counter code pythonic

2006-04-10 Thread jnair
My Team Lead says 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()