[Twisted-Python] Escaping variable names

Hi, Ive got an issue where a variable name needs to have a minus sign (-) in it. 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? Thanks!

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: server.doGetCountries(**{ '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. Bye, Maarten

Hello Maarten, Friday, March 5, 2010, 6:26:36 PM, you wrote:
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:
server.doGetCountries(**{ 'country-code': COUNTRYID, 'webapi-key': WEBAPIKEY })
The above gives a syntax error...
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.
Unfortunately the designer of the API is a large British company that forgot to take into account other languages than PHP.

On Friday 05 March 2010, Kamil Wasilewski wrote:
server.doGetCountries(**{ 'country-code': COUNTRYID, 'webapi-key': WEBAPIKEY })
The above gives a syntax error...
What kind of syntax error? I tested this approached on the interactive Python shell and it worked fine there:
def f(**kvargs): ... print kvargs ... f(a = 1, **{'b-c': 12}) {'a': 1, 'b-c': 12}
Bye, Maarten

On Friday 05 March 2010, Kamil Wasilewski wrote:
server.doGetCountries(**{ 'country-code': COUNTRYID, 'webapi-key': WEBAPIKEY })
The above gives a syntax error...
What kind of syntax error? I tested this approached on the interactive Python shell and it worked fine there:
def f(**kvargs): ... print kvargs ... f(a = 1, **{'b-c': 12}) {'a': 1, 'b-c': 12}
hu, it did work.. must of been a mistake on my part. But i tried that method a few times. Well that solved a problem ive been sitting on for a while. Thank you!

On Mar 5, 2010, at 12:15 PM, Kamil Wasilewski wrote:
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?
Thanks!
try: server.doGetCountries(**{'country-code':COUNTRYID, 'webapi-key':WEBAPIKEY}) -phil
participants (3)
-
Kamil Wasilewski
-
Maarten ter Huurne
-
Phil Christensen