I personally like this solution the best. Thanks mr.<br><br>
tuples = [(1, 2), (3, 4, 5), (6, 7)]<br>
<br>
def triple_or_pair(seq):<br>
    u = None<br>
    try:<br>
        k, u, v = seq<br>
    except ValueError:<br>
        k, v = seq<br>
    return k, u, v<br>
<br>
for k, u, v in [ triple_or_pair(seq) for seq in tuples ]:<br>
    print k, u, v<br><br><div class="gmail_quote">On Sat, Jan 3, 2009 at 4:55 AM, Kottiyath <span dir="ltr"><<a href="mailto:n.kottiyath@gmail.com">n.kottiyath@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On Jan 3, 2:38 am, mr <<a href="mailto:mario.rugg...@gmail.com">mario.rugg...@gmail.com</a>> wrote:<br>
> As has been noted, the best is to fix the input to be regular-3-<br>
> tuples. For the fun of it, here's another variation of a solution:<br>
><br>
> tuples = [(1, 2), (3, 4, 5), (6, 7)]<br>
><br>
> def triple_or_pair(seq):<br>
>     u = None<br>
>     try:<br>
>         k, u, v = seq<br>
>     except ValueError:<br>
>         k, v = seq<br>
>     return k, u, v<br>
><br>
> for k, u, v in [ triple_or_pair(seq) for seq in tuples ]:<br>
>     print k, u, v<br>
<br>
</div>It is a code to post some data to HTML server.<br>
Even though usually the POST values are of type(name, value), if file<br>
transfer is involved, then POST values change to (name, filename,<br>
value).<br>
My view was that since filename is a rare occurance and doesnt make<br>
sense in a usual POST, I had not kept it as a full 3 tuple.<br>
Since so many programmers (that too much more capable than me) are<br>
suggesting that it is code smell, I am reviewing my decision.<br>
<div><div></div><div class="Wj3C7c">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>А-Б-В-Г-Д-Е-Ё-Ж-З-И-Й-К-Л-М-Н-О-П-Р-С-Т-У-Ф-Х-Ц-Ч-Ш-Щ-Ъ-Ы-Ь-Э-Ю-Я<br>а-б-в-г-д-е-ё-ж-з-и-й-к-л-м-н-о-п-р-с-т-у-ф-х-ц-ч-ш-щ-ъ-ы-ь-э-ю-я<br>