On Thu, Aug 24, 2017 at 8:40 PM, Ben Finney <ben+pyt...@benfinney.id.au> wrote:
> Paul Rubin <no.email@nospam.invalid> writes:
>
>> Ben Finney <ben+pyt...@benfinney.id.au> writes:
>> >     generate_id = functools.partial(next, itertools.count())
>>
>> Is something wrong with:
>>
>>     >>> g = itertools.count().next
>
> I wasn't looking for a ‘next’ method on the iterator. Is that special to
> the ‘itertools.count’ type?
>
> If so, I was attempting to give the more general solution to “how do I
> get a function that will give me the next thing from this iterator”.

It's on all iterators; it's the Py2 equivalent for __next__. When you
call next(x), Py2 calls x.next(), which - being an inconsistent name -
got renamed to the more appropriate __next__() in Py3.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to