TypeError: iterable argument required

Mel mwilson at the-wire.com
Mon Apr 4 16:38:59 CEST 2011


Νικόλαος Κούρας wrote:

>> > 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',)
>>

> 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' .....

My wild guess is that the trouble is in `if "@" in mail` .  You can only
test somthing `in` something if the second thing is iterable.  So when
you don't supply a value via `?mail=' -- maybe the code that sets the
value of `mail` from the URL (code you don't show us) sets `mail=None`,
your server-side code blows up.  Things would be simpler if you included
a traceback in your error logging.

	Mel.




More information about the Python-list mailing list