khany wrote:
On 19 Oct, 14:44, StarWing <weasley...@sina.com> wrote:
On Oct 19, 9:15 pm, khany <sharif.k...@gmail.com> wrote:





On 19 Oct, 13:44, khany <sharif.k...@gmail.com> wrote:
<snip>
however it fails to create the string UNLESS i remove the colon (:) in
the http section. i tried to substitute it with chr(58) but it errors
the same without showing why. does anyone know what i am doing wrong?
is this peculiar to googleapps?
<snip>
)
here is the code ======
  xml = <?xml version="1.0" encoding="utf-8"?> \
    <findItemsAdvancedRequest xmlns=ttp://www.ebay.com/marketplace/
search/v1/services"> \
    <categoryId>%(category)i</categoryId> \
    <keywords>%(searchtext)s</keywords> \
    <paginationInput> \
      <pageNumber>%(page)i</pageNumber> \
      <entriesPerPage>10</entriesPerPage> \
    </paginationInput> \
    </findItemsAdvancedRequest>' % \
    {'category':9834, 'searchtext':"bmw", 'page':1}
  print xml
======
if i run this, the page is blank (even the source) with no errors or
anything. if i remove the colon from the string (after the http) it
prints the string on the browser fine.
HTH
you can use a tri-quote string or make sure all lines end with \:
<snip>
StarWing,

The triple String works a treat thanks. Not sure what the colon issue
was though. Now im getting Unsupported verb errors but thats an ebay
API issue i can work with.

Thanks to all for your help

khany

The original version worked fine in Python 2.6.2, once I combined the line that the email/listserver split for us. I also don't know what the colon issue was; I suspect some other change happened at the same time you changed the colon.

I also recommend the triple quote, for a few reasons. It avoids the risk that you'll forget one of the trailing backquotes. It avoids the risk of having an extra space after the backquote (most editors don't show the spaces, I insist on visible whitespace). And it lets you make the resulting string readable in source form.

However, for long strings, I strongly recommend you not combine the string assignment with the % formatting logic. So I'd use a couple of lines, something like:

    format_string = """This
is
my formatted
  string %(formatfield)
with some indentation preserved"""
  xml = format_string % (.....)

You should consider running the program locally, and redirect the output into a text file. Then you can examine exactly what's being produced. Sometimes the browser adds its own surprises. I don't know anything about the googleapps constraints.

DaveA

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to