[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__ == "_
[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
[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
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
Ok got it .
Thanks a Lot
--
http://mail.python.org/mailman/listinfo/python-list
[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()
>
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()