Re: [Zope] dtml-in and tuples
Chris Withers writes: > Why and how are python tuples (like, this) handled differently (and not > in a logical way I can see...) than python lists [like, this]? The "how" has been explained already. The "why" is only my guess: support for the widespread idiom ".items()", "objectItems" etc. Form the DTML reference: sequence-key The key associated with the element in an items sequence. An items sequence is a sequence of value pairs that represent a mapping from a key to a value. Dieter ___ Zope maillist - [EMAIL PROTECTED] 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 )
Re: [Zope] dtml-in and tuples
Shane Hathaway wrote: > > I don't know of any place. It ought to be in the DTML reference. I guess I'll hope and wait for the Zope Book :-) cheers, Chris ___ Zope maillist - [EMAIL PROTECTED] 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 )
Re: [Zope] dtml-in and tuples
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 ___ Zope maillist - [EMAIL PROTECTED] 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 )
Re: [Zope] dtml-in and tuples
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 ___ Zope maillist - [EMAIL PROTECTED] 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 )
Re: [Zope] dtml-in and tuples
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 ___ Zope maillist - [EMAIL PROTECTED] 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 )
Re: [Zope] dtml-in and tuples
"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 ___ Zope maillist - [EMAIL PROTECTED] 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 )
Re: [Zope] dtml-in and tuples
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 <[EMAIL PROTECTED]> > > Why and how are python tuples (like, this) handled differently (and not > > in a logical way I can see...) than python lists [like, this]? ___ Zope maillist - [EMAIL PROTECTED] 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 )
Re: [Zope] dtml-in and tuples
Well in Python a list is mutable and a tuple is not. --jfarr - Original Message - From: Chris Withers <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> 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 - [EMAIL PROTECTED] > 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 ) > ___ Zope maillist - [EMAIL PROTECTED] 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 )
[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 - [EMAIL PROTECTED] 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 )