Splitting the Tuple

1 view
Skip to first unread message

si...@mungewell.org

unread,
Jun 23, 2010, 10:07:41 PM6/23/10
to python...@googlegroups.com
Any one have a good way of splitting a tuple into parts, without storing
it in intermediate variables?

--
>>> print plctime(2009,0,1,0,0,34.+5.)
1230768039.0

>>> UTCFromGps(1587, 259197.00, leapSecs=14)
(2010, 6, 8, 23, 59, 43.0)

>>> print plctime(UTCFromGps(1587, 259197.00, leapSecs=14))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/dist-packages/plplotc.py", line 298, in plctime
return _plplotc.plctime(*args)
TypeError: plctime() takes exactly 6 arguments (1 given)

>>> (year,month,day,hour,minute,second)=UTCFromGps(1587, 259197.00,
leapSecs=14)

>>> plctime(year,month,day,hour,minute,second)
1278633583.0
--

Cheers,
Simon.

David Glass

unread,
Jun 23, 2010, 11:12:12 PM6/23/10
to python...@googlegroups.com
If I am understanding what you want to do, I think you are trying to change the tuple into the args of the function?

If that is the case, I think you want to put a * in front of the UTCFromGps in your third example:

print plctime(*UTCFromGps(1587, 259197.00, leapSecs=14))


--
You received this message because you are subscribed to the Google Groups "calgary python user group" group.
To post to this group, send email to python...@googlegroups.com.
To unsubscribe from this group, send email to pythoncalgar...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pythoncalgary?hl=en.


si...@mungewell.org

unread,
Jun 24, 2010, 12:54:03 AM6/24/10
to python...@googlegroups.com

> print plctime(*UTCFromGps(1587, 259197.00, leapSecs=14))
>

Yep that works, thanks.... why would have thought it would be so simple.
Simon

Reply all
Reply to author
Forward
0 new messages