what is wrong with my code?

Pyenos pyenos at pyenos.org
Wed Dec 20 17:16:58 EST 2006


import cPickle, shelve

could someone tell me what things are wrong with my code?

class progress:

    PROGRESS_TABLE_ACTIONS=["new","remove","modify"]
    DEFAULT_PROGRESS_DATA_FILE="progress_data"
    PROGRESS_OUTCOMES=["pass", "fail"]


    def unpickleProgressTable(pickled_progress_data_file):

        return unpickled_progress_table

    def pickleProgressTable(progress_table_to_pickle):

        return pickled_progress_data_file

    # Of course, you get progress_table is unpickled progress table.
    def progressTable(progress_table, action, task, pid=len(progress_table), outcome=PROGRESS_OUTCOMES[1]):
        pid_column_list=progress_table[0]
        task_column_list=progress_table[1]
        outcome_column_list=progress_table[2]
        
        # But a task must also come with an outcome!
        def newEntry(new_task, new_outcome):
            new_pid=len(task_column_list)

            pid_column_list.extend(new_pid)
            task_column_list.extend(new_task)
            outcome_column_list.extend(new_outcome)

        def removeEntry(pid_to_remove, task_to_remove):
            
            if pid_column_list.index(pid_to_remove)==task_column_list.index(task_to_remove):
                # Must remove all columns for that task
                index_for_removal=pid_column_list.index(pid_to_remove)

                pid_column_list.remove(index_for_removal)
                task_column_list.remove(index_for_removal)
                outcome_column_list.remove(index_for_removal)

        # Default action is to modify to pass
        def modifyEntry(pid_to_modify, outcome_to_modify=PROGRESS_OUTCOMES[0]):
            index_for_modifying=pid_column_list.index(pid_to_modify)
            
            # Modify the outcome
            outcome_column_list[index_for_modifying]=outcome_to_modify



More information about the Python-list mailing list