TypeError: iterable argument required

Discussion in 'Python' started by Íéêüëáïò Êïýñáò, Apr 2, 2011.

  1. 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',)
    **************************************************************

    can you help please?
    Íéêüëáïò Êïýñáò, Apr 2, 2011
    #1
    1. Advertising

  2. Íéêüëáïò Êïýñáò

    MRAB Guest

    On 02/04/2011 17:26, Íéêüëáïò Êïýñáò 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',)
    > **************************************************************
    >
    > can you help please?


    Which version of Python?

    Can you please paste those few lines of code (say, lines 163 to 170).

    I can't see what the "mail = None, comment = None" is meant to be.
    MRAB, Apr 2, 2011
    #2
    1. Advertising

  3. 2011/4/3 MRAB <>:
    > I can't see what the "mail = None, comment = None" is meant to be.


    If this is to reset the two variables after inserting into the
    database, you may want to use either:

    mail = None; comment = None # semicolon not comma
    or
    mail = comment = None # chaining assignment

    Is that the line with the error, though?

    Chris Angelico
    Chris Angelico, Apr 2, 2011
    #3
  4. On 2 ΑπÏ, 19:50, MRAB <> wrote:
    > On 02/04/2011 17:26, Ãéêüëáïò Êïýñáò 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 commentnot 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',)
    > > **************************************************************

    >
    > > can you help please?

    >
    > Which version of Python?
    >
    > Can you please paste those few lines of code (say, lines 163 to 170).
    >
    > I can't see what the "mail = None, comment = None" is meant to be.


    Is the same lines i posted in the 1st post

    **************************************************************
    # insert guest comments into database if form was submitted
    if "@" in mail and comment not in ("Σχολιάστε ή Ïωτήστε με
    σχετικά....", ""):
    try:
    cursor.execute( '''INSERT INTO users(mail, comment) VALUES(%s,
    %s)''', (mail, comment) )
    except MySQLdb.Error:
    print ( "Error %d: %s" % (e.args[0], e.args[1]) )
    **************************************************************

    Also both mail and comment variables are taken from input in form
    fields.

    mail = form.getvalue('mail')
    comment = form.getvalue('comment')
    Íéêüëáïò Êïýñáò, Apr 2, 2011
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    346
    James Stroud
    Dec 10, 2008
  2. eryksun ()
    Replies:
    3
    Views:
    457
    Íéêüëáïò Êïýñáò
    Apr 4, 2011
  3. eryksun ()
    Replies:
    2
    Views:
    758
    Terry Reedy
    Apr 6, 2011
  4. eryksun ()
    Replies:
    3
    Views:
    282
    Blockheads Oi Oi
    Apr 6, 2011
  5. Ana Dionísio

    TypeError: 'float' object is not iterable

    Ana Dionísio, Mar 14, 2013, in forum: Python
    Replies:
    8
    Views:
    242
    Dennis Lee Bieber
    Mar 14, 2013
Loading...

Share This Page