A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2006-February/060569.html below:

[Python-Dev] _length_cue()

[Python-Dev] _length_cue()Armin Rigo arigo at tunes.org
Thu Feb 9 00:51:56 CET 2006
Hi Raymond,

On Wed, Feb 08, 2006 at 03:02:21PM -0500, Raymond Hettinger wrote:
> IMHO, the "safety reasons" are imaginary -- the scenario would involve 
> subclassing one of these builtin objects and attaching an identically named 
> private method.

No, the senario applies to any user-defined iterator class, not
necessary subclassing an existing one:

>>> class MyIter(object):
...     def __iter__(self):
...         return self
...     def next(self):
...         return whatever
...     def _length_cue(self):
...         print "oups! please, CPython, don't call me unexpectedly"
...
>>> list(MyIter())
oups! please, CPython, don't call me unexpectedly
(...)

This means that _length_cue() is at the moment a special method, in the
sense that Python can invoke it implicitely.

This said, do we vote for __length_hint__ or __length_cue__? :-)
And does anyone objects about __getitem_hint__ or __getitem_cue__?
Maybe __lookahead_hint__ or __lookahead_cue__?


Armin
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4