Ordering of urlencoded tuples incorrect

benlucas99 at googlemail.com benlucas99 at googlemail.com
Fri Jan 16 01:59:54 CET 2009

I'm having problems with the ordering of the tuples produced by
urllib.urlencode.  Taking an example straight from the docs and so
doing the following:

	import urllib
	params = urllib.urlencode({'spam': 1, 'eggs': 2, 'bacon': 0})
	print params

The documentation for urlencode( query[, doseq]) says: "The order of
parameters in the encoded string will match the order of parameter
tuples in the sequence" but I'm getting:


Should this not produce: "spam=1&eggs=2&bacon=0" ?

I am seeing this "incorrect" result using Python 2.5.1 and
ActivePython 2.3.2 (both on XP SP2).  What am I doing wrong?  I've
been googling around for an answer but I'm a Python newbie and so
don't know the ropes yet.

Thanks for any help.


More information about the Python-list mailing list