Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RangeWidget argument check #4

Open
yoavram opened this issue Dec 26, 2013 · 3 comments
Open

RangeWidget argument check #4

yoavram opened this issue Dec 26, 2013 · 3 comments

Comments

@yoavram
Copy link

yoavram commented Dec 26, 2013

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

@rgbkrk
Copy link

rgbkrk commented Dec 26, 2013

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.

@rgbkrk
Copy link

rgbkrk commented Dec 26, 2013

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)

@yoavram
Copy link
Author

yoavram commented Jan 6, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants