I am trying to learn python after spending the last 15 years working only on Perl and only occasionally.
I can't figure out how to handle two different results from the parse method from Calendar.parse () from parsedatetime
Given this script:
import parsedatetime.parsedatetime as pdt
import parsedatetime.parsedatetime_consts as pdc
import sys
import os
c = pdc.Constants()
p = pdt.Calendar(c)
while True:
reply = raw_input('Enter text:')
if reply == 'stop':
break
else:
result = p.parse(reply)
print result
print
And this launch sample:
Enter the text: tomorrow
(time.struct_time (tm_year = 2009, tm_mon = 11, tm_mday = 28, tm_hour = 9, tm_min = 0, tm_sec = 0, tm_wday = 5, tm_yday = 332, tm_isdst = -1), 1)
Enter the text: 11/28
((2009, 11, 28, 14, 42, 55, 4, 331, 0), 1)
I cannot figure out how to get the output so that I can use the result like this:
print result[0].tm_mon, result[0].tm_mday
This will not work if the input is "11/28", because the output is just a tuple, not a struct_time.
, , . Calendar.parse() . . .