how to break tuple to separate variables

Larry Bates lbates at swamisoft.com
Tue Apr 13 10:07:19 EDT 2004


Take a look at the built-in apply function:

apply(datetime.date, date2tuple('2004-11-03'))

Larry Bates
Syscon, Inc.


"Stano Paska" <Stanislav.Paska at kios.sk> wrote in message
news:mailman.572.1081846104.20120.python-list at python.org...
> 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