Feb 12th, 2007, 6:22 PM
|
#5
|
|
Newbie
Join Date: Feb 2007
Posts: 13
Rep Power: 0 
|
Quote:
Originally Posted by Arevos
If you want to access an element of a tuple, you can use indices, in the same way you would an array or list:
result = (datetime.date(2007, 2, 9),) date = result[0] print date.strftime("%Y-%m-%d")
Or simply:
print result[0].strftime("%Y-%m-%d")
You can also assign a tuple to an set of variables to get its contents:
coords = (4, 6) x, y = coords
And for a tuple with a single value:
result = (datetime.date(2007, 2, 9),) date, = result
This notation when applied to only one value is a little obscure, however.
|
Thanks for this. I tried out all these methods and kept coming up with this error:
AttributeError: 'tuple' object has no attribute 'strftime'
I can't figure out why this isn't working as it seems pretty straightfoward. 
|
|
|