[Twisted-Python] Escaping variable names

Maarten ter Huurne maarten at treewalker.org
Fri Mar 5 12:26:36 EST 2010

On Friday 05 March 2010, Kamil Wasilewski wrote:

> from SOAPpy import WSDL
> wsdlFile = "http://webapi.allegro.pl/uploader.php?wsdl"
> server = WSDL.Proxy(wsdlFile)
> server.soapproxy.config.argsOrdering = {'doGetCountries':
> ['country-code', 'webapi-key'] }
> server.doGetCountries(country-code=COUNTRYID}, webapi-key=WEBAPIKEY)
> The above method allows me to specify the order and name of variables
> being sent, but i have a problem since the variables have a "-" sign in
> the middle, is there a way to escape it in the variable name or get
> around the problem?

Yes, you can pass them from a dictionary using the ** syntax:

	'country-code': COUNTRYID, 'webapi-key': WEBAPIKEY

However, if you have the ability to change the API, it would be better to 
use underscores as separators in the argument names instead of dashes.


More information about the Twisted-Python mailing list