[Zope] odd iteration semantics in ZPT
dman
dman@dman.ddts.net
Thu, 9 May 2002 11:48:05 -0500
--KDt/GgjP6HVcx58l
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Wed, May 08, 2002 at 10:37:12PM +0200, Dieter Maurer wrote:
| dman writes:
| > ....
| > I managed to track it down to the fact that
| > __getitem__ is called twice with 0 as the index. The sequence of
| > index values looks like : [0, 0, 1, 2, 3, 4, 5, 6, 7, 8]
| > I can work around this anomaly by resetting my iterator every time the
| > index is 0.
| >=20
| > Is this a bug in zope? (I expect that the bug is in ZTUtils/Iterator.=
py)
|
| I do not call this a bug, because there is not spec that forbids to
| call an index twice.
I suppose you may have a point ... the problem lies in python's
pre-iterators iteration semantics. The __getitem__ serves as the
interface for both a random-access collection and a one-way iterator.
I expected tal:repeat to have the same semantics as python's 'for'.
At the least it should be defined that tal:repeat only works on
random-access containers and doesn't work with one-way iterators.
-D
--=20
How great is the love the Father has lavished on us,
that we should be called children of God!
1 John 3:1=20
=20
GnuPG key : http://dman.ddts.net/~dman/public_key.gpg
--KDt/GgjP6HVcx58l
Content-Type: application/pgp-signature
Content-Disposition: inline
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iEYEARECAAYFAjzaqEUACgkQO8l8XBKTpRRkDwCeMnqz+kZWGmjyZMA1BaYRIJFp
7qoAn0pj6gxXYuTt713WJh5KXA7NVrVv
=dl/r
-----END PGP SIGNATURE-----
--KDt/GgjP6HVcx58l--