[Tutor] Reading List from File

Emile van Sebille emile at fenx.com
Thu Jul 31 20:34:56 CEST 2008

S Python wrote:
>>>> f = open(r'C:\test.txt', 'r')
>>>> foo = f.readline.split(',')

readline is the function/method name
readline() executes that function/method and returns a value

try typing in 'type(f.readline)' vs 'type(f.readline())'

you can't .split() a function but you may split its return value.

> but it fails when I try:
>>>> import csv
>>>> myfile = open(r'c:\test.txt', 'r')
>>>> data = csv.Reader(myfile, delimeter = ',')

Python is case sensitive -- reader is different from Reader.



More information about the Tutor mailing list