object not iterable

385 views
Skip to first unread message

Rockmaster

unread,
Jan 6, 2009, 5:01:36 PM1/6/09
to Google App Engine
Hi, there,

I've been trying to figure out what is happening with my code, and
after pounding my head against the wall for a while, I thought I'd ask
you guys.

I'm trying to extract some lines containing "X=" from an inputform.
Here's the portion of code that is giving me trouble:

inputdata = self.request.get('inputdata')
nlines = inputdata.splitlines
xlines = []
for val in nlines:
if val.find('X='):
xlines.append(val)

Here's the error I get:
for val in nlines:
TypeError: 'builtin_function_or_method' object is not iterable

I thought that splitlines would return a list, which should be
iterable, right?

Ross M Karchner

unread,
Jan 6, 2009, 5:10:36 PM1/6/09
to google-a...@googlegroups.com
"inputdata.splitlines" refers to the function itself, you want to *call* the function, so use parentheses:

nlines = inputdata.splitlines()

Rockmaster

unread,
Jan 6, 2009, 5:23:41 PM1/6/09
to Google App Engine
Thanks!
Reply all
Reply to author
Forward
0 new messages