def s(flag=None): """ s is abbreviation for show Show the last question-answer group if flag == 1, will show question index in doubt_list""" if not doubt_log: return 'Doubt log is empty' last_log_key = sorted(doubt_log.keys())[-1] last_datetime = str(datetime.fromtimestamp(last_log_key))[:19] print last_datetime, '\n' for sub_log_key in sorted(doubt_log[last_log_key].keys()): question = doubt_log[last_log_key][sub_log_key] answer_list = doubt_all[question] q_index = '' if flag == 1: q_index = doubt_list.index(question) print question, q_index if answer_list: for answer in answer_list: print answer print '\n' save()
def d(question=None): """ d is abbreviation for doubt Ay, ay, ay, people would die withoud docs after reviewing their own code after a month """ if question: if doubt_all.get(question): q_index = doubt_list.index(question) return 'This question already exists, with question index %d' % q_index question = question or raw_input() doubt_all[question] = None # A question without answer doubt_list.append(q) # make index for question q = question global q current_time = time.time() if doubt_log.keys(): log_time_stamp = sorted(doubt_log.keys())[-1] sub_stamp = sorted(doubt_log[log_time_stamp].keys())[-1] if current_time - sub_stamp <= 1800: doubt_log[log_time_stamp][current_time] = question else: doubt_log[current_time] = {current_time: question} else: doubt_log[current_time] = {current_time: question} save()