{"html_url": "https://github.com/simonw/datasette/issues/203#issuecomment-380966565", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/203", "id": 380966565, "node_id": "MDEyOklzc3VlQ29tbWVudDM4MDk2NjU2NQ==", "user": {"value": 45057, "label": "russss"}, "created_at": "2018-04-12T22:43:08Z", "updated_at": "2018-04-12T22:43:08Z", "author_association": "CONTRIBUTOR", "body": "Looks like [pint](https://pint.readthedocs.io/en/latest/tutorial.html) is pretty good at this.\r\n\r\n```python\r\nIn [1]: import pint\r\n\r\nIn [2]: ureg = pint.UnitRegistry()\r\n\r\nIn [3]: q = 3e6 * ureg('Hz')\r\n\r\nIn [4]: '{:~P}'.format(q.to_compact())\r\nOut[4]: '3.0 MHz'\r\n\r\nIn [5]: q = 0.3 * ureg('m')\r\n\r\nIn [5]: '{:~P}'.format(q.to_compact())\r\nOut[5]: '300.0 mm'\r\n\r\nIn [6]: q = 5 * ureg('')\r\n\r\nIn [7]: '{:~P}'.format(q.to_compact())\r\nOut[7]: '5'\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 313837303, "label": "Support for units"}, "performed_via_github_app": null}