Movatterモバイル変換


[0]ホーム

URL:


[Python-Dev] [Python-ideas] Expose `itertools.count.start` and implement `itertools.count.__eq__` based on it, like `range`.

Nick Coghlanncoghlan at gmail.com
Sat Jun 7 11:50:50 CEST 2014


On 7 June 2014 19:36, Ram Rachum <ram.rachum at gmail.com> wrote:> My need is to have an infinite immutable sequence. I did this for myself by> creating a simple `count`-like stateless class, but it would be nice if that> behavior was part of `range`.Handling esoteric use cases like it sounds yours was is *why* userdefined classes exist. It does not follow that "I had to write acustom class to solve my problem" should lead to a standard library orbuiltin changing unless you can make a compelling case for:* the change being a solution to a common problem that a lot of otherpeople also have. "I think it might be nice" and "it would have beenuseful to me to help solve this weird problem I had that one time"isn't enough.* the change fitting in *conceptually* with the existing language andtools. In this case, "infinite sequence" is a fundamentally incoherentconcept in Python - len() certainly won't work, and negative indexingbehaviour is hence not defined. By contrast, since iterables anditerators aren't required to support len() the way sequences are,infinite iterable and infinite iterator are both perfectly welldefined.Cheers,Nick.-- Nick Coghlan   |ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-Devmailing list

[8]ページ先頭

©2009-2025 Movatter.jp