how to break tuple to separate variables

Stano Paska Stanislav.Paska at kios.sk
Tue Apr 13 04:48:00 EDT 2004


Hi.

I need pass variables to function like tuple, but function accepts 
separate variables.

Is there some elegant solution?

My example:

# -------------------------------
import datetime

def date2tuple(aaa):
     try:
         y = int(aaa[:4])
         m = int(aaa[5:7])
         d = int(aaa[8:10])
     except:
         y = m = d = 0
     return (y, m, d)

# i need some like this
bbb = datetime.date(date2tuple('2004-11-03'))

# but date requires
bbb = datetime.date(2004, 11, 03)

# -------------------------------

Thanks.

Stano Paska






More information about the Python-list mailing list