#!/usr/bin/env python3
from random import choice
class StudentPicker(object):
def __init__(self, students):
with open(students, 'r') as student_file:
students = student_file.readlines()
students = filter(None, students)
students = [s.strip().split('\t') for s in students]
self._students = ["%s %s, %s" % (s[0], s[1], s[2]) for s in students]
self._initial_students = list(self._students)
def pick_student(self):
"""
Return a student and remove that student from the list.
"""
try:
student = choice(self._students)
self._students.remove(student)
return student
except IndexError:
return "no more students available; use 'reset' or 'quit'"
def reset(self):
self._students = list(self._initial_students)