[Zope] ZPT reverse ordering
dman
dman@dman.ddts.net
Fri, 3 May 2002 08:51:42 -0500
--bp/iNruPH9dso1Pn
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
On Fri, May 03, 2002 at 10:39:29AM +0100, Tom Nixon wrote:
| > python:sequence.sort(thelist,(('bobobase_modification_time','d
| > esc'),))">
|=20
| Thanks for your help. I get an error when I try this though:
|=20
| Error Type: TALESError
| Error Value: exceptions.AttributeError on 'None' object has no attribute
| 'getitem' in "", at line 160, column 3
>>> l =3D [ 3 , 2 ]
>>> print l
[3, 2]
>>> print l.sort()
None
>>> print l
[2, 3]
>>>=20
The sort() method modifies the list in-place and returns None. You
are trying to iterate over the return value of sort(), which doesn't
have a getitem method.
The simplest solution is to sort the list after you have a reference
to it. Eg:
tal:define=3D"l python:[3,2] ; foo l.sort()"
As a side effect it creates 'foo' as a reference to None, but that
isn't significant.
-D
--=20
An anxious heart weighs a man down,
but a kind word cheers him up.
Proverbs 12:25
=20
GnuPG key : http://dman.ddts.net/~dman/public_key.gpg
--bp/iNruPH9dso1Pn
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
iEYEARECAAYFAjzSle4ACgkQO8l8XBKTpRTeggCeNzdLBt2xrJNW6m/HdkISgFZq
hCkAoJ0utnpPYCtORmmUxYrHPwy7t7Iq
=tzU7
-----END PGP SIGNATURE-----
--bp/iNruPH9dso1Pn--