Пример #1
0
def r(question=None):
    """ r is abbreviation for reply"""
    if not question:
        if 'q' in globals():
            question = q
        else:
            return "We don't have any questions yet"

    elif type(question) is int:
        if len(doubt_list) > question:
            question = doubt_list[question]

    elif not doubt_all.get(question):
        return "We don't have any questions yet"

    your_answer = raw_input()

    if doubt_all.get(question):
        doubt_all[question].append(your_answer)
    else:
        doubt_all[question] = [your_answer]

    a = doubt_all[question][-1]
    global a
    save()
Пример #2
0
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()
Пример #3
0
def view(q1):
    if doubt_all.get(q1):
        return doubt_all[q1]
    else:
        return 'now answer for this question yet'