How to handle a value being received as string or int in python?

My service works with both SOAP and REST.

When clients use SOAP to connect to my server I get their numerical input as integer / float values, while if they use REST for the same input I get string values. So far I had to use double parsing:

str(int(input_value)) or str(float(input_value))

which is not a good solution.

Is there any better way to deal with this in Python 2/3.x?

Or, is there a way of stopping REST numerical input being sent as strings?

Source: python

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.