On Wed, Oct 12, 2011 at 11:51 AM, MRAB <pyt...@mrabarnett.plus.com> wrote:
>> Aside:
>>
>> I'm astonished to see that range objects have a count method! What's the
>> purpose of that? Any value's count will either be 0 or 1, and a more
>> appropriate test would be `value in range`:
>>
>>  >>> 17 in range(2, 30, 3) # like r.count(17) => 1
>> True
>>  >>> 18 in range(2, 30, 3) # like r.count(18) => 0
>> False
>>
> In Python 2, range returns a list, and lists have a .count method.
> Could that be the reason?

Python 2 xrange objects do not have a .count method.  Python 3 range
objects do have a .count method.  The addition is curious, to say the
least.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to