Closed adarshk7 closed 8 years ago
I, personally, don't like the (nicely put) "repurposing" of tuple and list literals for the definition of open or closed intervals. While this is the usual mathematical syntax, it means something different in Python. This is not operator overloading.
Especially the fact that the creation of an open/closed or closed/open interval requires a different syntax (i.e. a string including parentheses or square brackets) just feels wrong and error-prone to me.
I'd like to compare this to Google Guava's Range
class (API docs) which uses clearly named, uniform, auto-completable factory methods ("open", "closed", "openClosed" etc.) for that purpose.
In summary, I propose to go the opposite direction and make the API more explicit, self-explanatory and, thus, Pythonic.
Guava-like factory methods have been added, closing this for now.
Guava-like factory methods have been added […]
@kvesteri, can you please point me to the commit that added this?
Ah, thanks!
For example,
IntInterval(3, 5) == IntInterval((3, 5)) and, IntInterval[3, 5] == IntInterval([3, 5])