Unpacking a single tuple _or_ a pair

Oleg Broytmann phd at phd.russ.ru
Mon Mar 13 10:26:37 EST 2000


On Mon, 13 Mar 2000, Peter Bittner wrote:
>   for i in range(len(datalist)):
>     try:
>       value, text = datalist[i]		# separate pair's values
>     except:
>       text, = datalist[i]	# assume single value on fail
>       value = ''

   Just check len(datalist[i])...

Oleg.
---- 
    Oleg Broytmann      Foundation for Effective Policies      phd at phd.russ.ru
           Programmers don't die, they just GOSUB without RETURN.





More information about the Python-list mailing list