Re: Is this code snippet pythonic

2006-04-10 Thread Felipe Almeida Lessa
Em Seg, 2006-04-10 às 03:52 -0700, [EMAIL PROTECTED] escreveu: > My Tead Lead my object counter code seen below is not pythonic As Peter said, you should really ask your Tead Lead, but what about: class E(object): """Holds a class-wide counter incremented when it's instantiated.""" co

Re: Is this code snippet pythonic

2006-04-10 Thread Kent Johnson
Peter Hansen wrote: > [EMAIL PROTECTED] wrote: >>> class E(object): >> _count = 0 >> def __init__(self): >> E._count += 1 >> count = property(lambda self: E._count ) > 2. You don't need the "self" in the lambda, since you're not using it > anyway. Yes he does, it's a propert

Re: Is this code snippet pythonic

2006-04-10 Thread Peter Hansen
[EMAIL PROTECTED] wrote: > My Tead Lead my object counter code seen below is not pythonic I'm guessing this was supposed to say "My team lead says my " (?) > class E(object): > _count = 0 > def __init__(self): > E._count += 1 > count = property(lambda self: E._count )

Is this code snippet pythonic

2006-04-10 Thread 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()