ipywidgets-static
ipywidgets-static copied to clipboard
RangeWidget argument check
First of all - this is awesome.
I ran RangeWidget(1,10,"turns") and it took me some time to understand that it's not working because the third argument is step.
I suggest to check the type of the arguments in widgets.py line 42.
If you agree than I can do it myself and create a PR
Cheers Yoav
Is "turns" supposed to be the name of the widget?
If so, you would want to specify the keyword.
RangeWidget(1, 10, name="turns")
step, name, default, width, divclass and show_range are all optional keyword arguments. If used in order they don't require a keyword, but if you want to "pick and choose" from them you have to be explicit.
It's worth pointing out that the RangeWidget was created with python's built-in range() in mind. range() takes step as it's last optional argument:
>>> range(1, 11)
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>> range(0, 30, 5)
[0, 5, 10, 15, 20, 25]
>>> range(0, 10, 3)
I agree with both your comments. I only suggest that you check the type of the supplied input because if the type is wrong then the error can be swallowed up somewhere inside the mechanism and they whole thing just doesn't work without explicitly failing. For example, if I run range with turns as the third paramter I get an explicit error: TypeError: range() integer step argument expected, got str.