[Tutor] Syntax error and EOL Error

Alan Gauld alan.gauld at btinternet.com
Mon Sep 7 11:24:44 CEST 2015


On 07/09/15 01:40, Nym City via Tutor wrote:
> Hello,
> Thank you for your response. I have made updates and here is the new code:
> import csv
> DomainList = []
>
> domains = open('domainlist.csv', 'rb')
> DomainList = csv.reader(domains)
> DomainList = [column[1] for column in DomainList(str.rstrip('/'))]

Since DomainList is a csv.reader object what made you think you could 
call it with a string argument? You were not doing that previously?

> For "DomainList = [column[1] for column in DomainList(str.rstrip('/'))]"
> line, I am getting following error:TypeError: '_csv.reader' object is not callable

Which is true, and should be obvious how to fix. Stop calling it.
That means don't have parentheses after it.

> Doing some research, i thought it might be because I am importing
 > the csv as 'r' only

You are not importing the csv as 'r' you are opening your file as 'r'.
This has nothing to do with the error.
That is because you are calling a non callable object.

> Also, not sure if the next error is because of the above issue but
 > I get syntax error when I do the last print

Can you tell us how you managed to get that second error?
The interpreter should have stopped after the first error so you
should never get a second error. You must have modified the
code in some way.

You would need to show us the actual code you ran to reach the print 
statement, otherwise we can't begin to guess what might be causing the 
syntax error.


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Tutor mailing list