SyntaxFix
Write A Post
Hire A Developer
Questions
Tags
This is ugly. What's a more Pythonic way to do it?
import datetime t= (2010, 10, 2, 11, 4, 0, 2, 41, 0) dt = datetime.datetime(t[0], t[1], t[2], t[3], t[4], t[5], t[6])
This question is related to python tuples
python
tuples
Refer https://docs.python.org/2/tutorial/controlflow.html#unpacking-argument-lists
dt = datetime.datetime(*t[:7])
Source: Stackoverflow.com