Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Decimal #35

Closed
jacobsvante opened this issue Mar 5, 2015 · 5 comments
Closed

Support Decimal #35

jacobsvante opened this issue Mar 5, 2015 · 5 comments

Comments

@jacobsvante
Copy link
Contributor

>>> import dicttoxml
>>> from decimal import Decimal
>>> mydict = dict(mydecimal=Decimal('1.2345'))
>>> dicttoxml.convert_dict(mydict, False, 'objects', True)
TypeError: Unsupported data type: 1.2345 (Decimal)
@jacobsvante
Copy link
Contributor Author

(Well at least it gives this more precise error when you've merged #34)

@quandyfactory
Copy link
Owner

You're right; dicttoxml should be able to accommodate Decimal values. Let me look into how best to implement this and I will push a fix shortly.

@quandyfactory
Copy link
Owner

It looks like the most generic way to test if an object is a number is to import numbers and then:

isinstance(mydecimal, numbers.Number)

Unless I find anything better, I'm going to implement this.

@quandyfactory
Copy link
Owner

I went with isinstance(mydecimal, numbers.Number) as it seems to be the most generic way to test if something is numbery. Thanks for bringing this issue to my attention!

@jacobsvante
Copy link
Contributor Author

Thank you @quandyfactory for fixing this! (Unlike what the README says 😉)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants