#NEWLINE# def urlencode( query ) : #NEWLINE# #INDENT# 'Encode a sequence of two-element tuples or dictionary into a URL query string.\n\n    Operates using an OAuth-safe escape() method, in contrast to urllib.urlencode.\n    ' #NEWLINE# if isinstance ( query , dict ) : #NEWLINE# #INDENT# query = query . items ( ) #NEWLINE# #UNINDENT# return '&' . join ( [ '=' . join ( [ escape ( k ) , escape ( v ) ] ) for ( k , v ) in query ] )