On 11/04/2012 14:50, Khalid Al-Ghamdi wrote:
Hi All,

I'm using python 3.2 on a windows xp.

I wrote the below script and ran it with the hope of returning a list of
proctors (list_proc), but when it runs it  doesn't call the function
convert_proctors() as intended. On the other hand, when i import the module
from the IDLE prompt and call the convert_proctors() function, the function
returns the desired list.

Why is this so?

Thanks


    1. import csv
    2.
    3. proctor_file=r'c:\Python32\Khalid Stuff\Testing_Scheduler\p
    roctors.csv'
    4.
    5.
    6. def convert_proctors():
    7.     proctor_csv_reader = csv.reader(open(proctor_file))
    8.     proctor_list=list(proctor_csv_reader)
    9.     list_proc=[]
    10.     for row in range(len(proctor_list)):
    11.         list_proc.append(proctor_list[row][0])
    12.     return (list_proc)
    13.
    14.
    15. convert_proctors()




_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Your main query has already been answered, but I'd like to point out that your function could be written something like this.

def convert_proctors():
    list_proc = []
    for row in csv.reader(open(proctor_file)):
        list_proc.append(row[0])
    return list_proc

--
Cheers.

Mark Lawrence.

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to