0

In many statistical applications, I'd like to type hint variables to be between two numbers (usually 0 and 1).

It would be best to hint that these variables are of type Interval[low, hi] or similar. How can I type hint this in python?

Demetri Pananos
  • 6,770
  • 9
  • 42
  • 73
  • it sounds like you want *dependent types*, but Python's type system doesn't really have that (indeed, it is not a common feature in most widely used languages – juanpa.arrivillaga Nov 23 '22 at 02:13
  • See [this for some more theoretical discussion](https://stackoverflow.com/questions/9338709/what-is-dependent-typing). I redirected the duplicate target, the original one had an accepted answer that did't do what was being implied by the title (rather, they used type annotations to enforce constraints *at runtime*) – juanpa.arrivillaga Nov 23 '22 at 02:16

0 Answers0