From b188c8e722fa2e1f4218867f6f0cde084a15dd31 Mon Sep 17 00:00:00 2001 From: Victor Shnayder Date: Tue, 15 Jan 2013 18:19:54 -0500 Subject: [PATCH] fix bug in string splitting. --- lms/djangoapps/instructor/views.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lms/djangoapps/instructor/views.py b/lms/djangoapps/instructor/views.py index 9a5a73e4e3..2a80b387d1 100644 --- a/lms/djangoapps/instructor/views.py +++ b/lms/djangoapps/instructor/views.py @@ -2,6 +2,7 @@ from collections import defaultdict import csv +import itertools import json import logging import os @@ -798,14 +799,15 @@ def _split_by_comma_and_whitespace(s): Split a string both by on commas and whitespice. """ # Note: split() with no args removes empty strings from output - return [x.split() for x in s.split(',')] + lists = [x.split() for x in s.split(',')] + # return all of them + return itertools.chain(*lists) def _do_enroll_students(course, course_id, students, overload=False): """Do the actual work of enrolling multiple students, presented as a string of emails separated by commas or returns""" - ns = _split_by_comma_and_whitespace(students) - new_students = [item for sublist in ns for item in sublist] + new_students = _split_by_comma_and_whitespace(students) new_students = [str(s.strip()) for s in new_students] new_students_lc = [x.lower() for x in new_students]