[ZPT] sequence unpacking syntax in TAL

Evan Simpson evan at 4-am.com
Fri Jul 11 16:01:37 EDT 2003


Fred L. Drake, Jr. wrote:
> This is a proposal to extend TAL to support sequence unpacking for the
> tal:define and tal:repeat attributes.

Looks workable.  I suggest that the unpack list should work even if 
there aren't as many names as elements in the sequence, that is:

 >>> name1, name2 = seq[:2]

It might be nice to allow a catchall variable for the sequence tail.  To 
emphasize the unpacking-nature (and to make parsing easier), we might 
want to use delimiters instead of commas, as in tal:define="[name1 name2 
*other] seq".

By analogy with this, we could also provide limited dict "unpacking" for 
keys that are valid variable names (common case in my experience), like 
tal:define="{key1 key2} mapvar".

Cheers,

Evan @ 4-am




More information about the ZPT mailing list