13-08-2009 azrael <jura.gro...@gmail.com> wrote:

j
[u'Tata', u'Oriovac', u'PrimorskoGoranska', u'hrvatska', u'Kuna']
len(j)
5
h = """SELECT distinct u.id_ulica, o.id_opcina, z.id_zupanija, d.id_drzava, v.id_valuta FROM ulica as u, opcina as o, zupanija as z, drzava as d, valuta as v WHERE u.naziv = '%s' AND o.naziv = '%s' AND z.naziv = '%s' AND d.naziv = '%s' AND v.naziv = '%s'""" % (j)
Traceback (most recent call last):
  File "<string>", line 1, in <string>
TypeError: not enough arguments for format string


I want to format the string. the list has five elements and the string
has five placeholder but it wont format the string

j must be a tuple -- so either define it as

    (u'Tata', u'Oriovac', u'PrimorskoGoranska', u'hrvatska', u'Kuna')

or when using it, wrap it with tuple() constructor:

    h = """...........""" % tuple(j)

--
Jan Kaliszewski (zuo) <z...@chopin.edu.pl>
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to