TypeError: iterable argument required

Νικόλαος Κούρας nikos.kouras at gmail.com
Mon Apr 4 09:40:33 EDT 2011


On 3 Απρ, 17:01, "eryksun ()" <eryk... at gmail.com> wrote:
> On Saturday, April 2, 2011 12:26:18 PM UTC-4, Νικόλαος Κούρας wrote:
> > Hello, after inserting this line if "@" in mail and comment not in
> > ("Σχολιάστε ή ρωτήστε με σχετικά....", ""):
>
> > iam getting the following error which i dont understand
>
> > **************************************************************
> > 163         # insert guest comments into database if form was
> > submitted
> >   164         if "@" in mail and comment not in ("Σχολιάστε ή ρωτήστε
> > με σχετικά....", ""):
> >   165                 try:
> >   166                         cursor.execute( '''INSERT INTO
> > users(mail, comment) VALUES(%s, %s)''', (mail, comment) )
> > mail = None, comment = None
>
> > TypeError: iterable argument required
> >       args = ('iterable argument required',)
>
> Here's how I parse what you've written so far:
>
> INVALID_COMMENTS = ("Σχολιάστε ή ρωτήστεμε σχετικά....", "")
> SQL_COMMENT_FORM = "INSERT INTO users(mail, comment) VALUES(%s, %s)"
>
> # insert guest comments into database if form was submitted
> mail = form.getvalue('mail')
> comment = form.getvalue('comment')
> if "@" in mail and comment not in INVALID_COMMENTS:
>     try:        
>         cursor.execute(SQL_COMMENT_FORM % (mail, comment))
>     except MySQLdb.Error as e:
>         print("Error %d: %s" % (e.args[0], e.args[1]))
>     else:
>         mail = comment = None

Whats was the problem as i have written it?
Your solution is the same as mine except the fact that you assign
values and statements into variables.
I tried it but iam getting an Internal Server Error.

In my original question can you explain to me what the meaning of the
following error is?

********************************************
mail = None, comment = None
TypeError: iterable argument required
      args = ('iterable argument required',)
*********************************************

Also i noticed that if i append a query string in the end of a url
with the varibble mail attached like

http://superhost.gr/hosting.html?mail=test

then page hosting.html does load without any problem.

If i remove the query string from the ned of the URL then i'am getting
the error message i posted.

So its not that the if condition is wrong but something happens with
the form variable 'mail' .....



More information about the Python-list mailing list