Is this code snippet pythonic

Kent Johnson kent at kentsjohnson.com
Mon Apr 10 11:13:58 EDT 2006


Peter Hansen wrote:
> jnair at ensim.com 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 property getter, it will be called with self as an 
argument.

Kent



More information about the Python-list mailing list