Hi, Why and how are python tuples (like, this) handled differently (and not in a logical way I can see...) than python lists [like, this]? cheers, Chris
Well in Python a list is mutable and a tuple is not. --jfarr ----- Original Message ----- From: Chris Withers <chrisw@nipltd.com> To: <zope@zope.org> Sent: Monday, August 14, 2000 3:38 PM Subject: [Zope] dtml-in and tuples
Hi,
Why and how are python tuples (like, this) handled differently (and not in a logical way I can see...) than python lists [like, this]?
cheers,
Chris
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
On Mon, 14 Aug 2000, Jonothan Farr wrote:
Well in Python a list is mutable and a tuple is not.
Right, but he's asking why dtml-in treats tuples in a special way, and exactly what that behavior is. --RDM
----- Original Message ----- From: Chris Withers <chrisw@nipltd.com>
Why and how are python tuples (like, this) handled differently (and not in a logical way I can see...) than python lists [like, this]?
"R. David Murray" wrote:
On Mon, 14 Aug 2000, Jonothan Farr wrote:
Well in Python a list is mutable and a tuple is not.
Right, but he's asking why dtml-in treats tuples in a special way, and exactly what that behavior is.
That's right :-) ..and in particular why it's so weird. It seems to do something like use return the last element of the tuple rather than return the tuple object... I'm just guessing though :S cheers, Chris
Chris Withers wrote:
"R. David Murray" wrote:
On Mon, 14 Aug 2000, Jonothan Farr wrote:
Well in Python a list is mutable and a tuple is not.
Right, but he's asking why dtml-in treats tuples in a special way, and exactly what that behavior is.
That's right :-)
..and in particular why it's so weird. It seems to do something like use return the last element of the tuple rather than return the tuple object...
Looking at the code, it appears that if you pass a list of two-element tuples, dtml-in will sort by the first element of each pair and render the second element. If, on the other hand, you pass a list of lists, it won't try to sort that way. Shane
Shane Hathaway wrote:
Looking at the code, it appears that if you pass a list of two-element tuples, dtml-in will sort by the first element of each pair and render the second element.
Unluckilly, that's exactly what I was passing it. But not the result I was looking for :S
If, on the other hand, you pass a list of lists, it won't try to sort that way.
Yeah, using just a list of length-two lists did the job :-) Can I be brave enough to ask why it does this and where it's documented (other than the source ;-) cheers, Chris
Chris Withers wrote:
Shane Hathaway wrote:
Looking at the code, it appears that if you pass a list of two-element tuples, dtml-in will sort by the first element of each pair and render the second element.
Unluckilly, that's exactly what I was passing it. But not the result I was looking for :S
If, on the other hand, you pass a list of lists, it won't try to sort that way.
Yeah, using just a list of length-two lists did the job :-)
Can I be brave enough to ask why it does this and where it's documented (other than the source ;-)
I don't know of any place. It ought to be in the DTML reference. Shane
participants (4)
-
Chris Withers -
Jonothan Farr -
R. David Murray -
Shane Hathaway