[Python-ideas] Units in type hints
Skip Montanaro
skip.montanaro at gmail.com
Thu May 14 16:05:07 CEST 2015
On Thu, May 14, 2015 at 6:03 AM, Koos Zevenhoven
<koos.zevenhoven at aalto.fi> wrote:
> How about extending the type annotations for int, float and complex to
> optionally include also a unit?
Not sure that's going to fly, but you might want to check out the
magnitude package:
https://pypi.python.org/pypi/magnitude/0.9.1
I've used it in situations where I want to specify units scaled to a
more natural (to me) size. For example, the gobject.timeout_add
function takes a delay in milliseconds. Given that most of the time I
want delays in seconds or minutes, it's much more natural for me to
let magnitude do the work silently.
Skip
More information about the Python-ideas
mailing list