Me wrote:

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
[snip]

PS. If you use Python 2.6 or newer, better use .format() method
(then you can use also a list):

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 = '{0}' AND o.naziv = \
... '{1}' AND z.naziv = '{2}' AND d.naziv = '{3}' AND v.naziv = '{4}'\
... """.format(*j)


Cheers,
*j

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

Reply via email to