[Tutor] need help with a script..

Christian Witts cwitts at compuscan.co.za
Wed Apr 11 16:00:50 CEST 2012


On 2012/04/11 03:50 PM, 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\proctors.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 at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
convert_proctors() will get called when you run the application from say 
the command line, but because there's no explicit printing of the 
resulting list it will never get displayed to your console. Whereas when 
you run it from IDLE it will implicitly print the return value of a 
function if you do not "save" the data to a variable.
-- 

Christian Witts
Python Developer
//
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20120411/320d6d9a/attachment.html>


More information about the Tutor mailing list