I just like to err on the safe side. I did not notice the recommendation
from the Python documentation. I changed as you suggested. :-)
On Friday, 11 October 2013 21:37:47 UTC-5, Stefan Pochmann wrote:
>
> I see you used unnecessary backslashes again in [\+\-], is that some
> web2py convention
Did you try that? It doesn't round that for me:
>>> int("3.14")
Traceback (most recent call last):
File "", line 1, in
int("3.14")
ValueError: invalid literal for int() with base 10: '3.14'
It does round int(3.14), so if floats are a possible input there, you could
do int(str(value)) inst
I see you used unnecessary backslashes again in [\+\-], is that some web2py
convention or so? It's equivalent to just [+-] and [-+] because inside
character classes, "+" is not a metacharacter and "-" acts as regular
character when placed right after "[" or right before "]". You can even
find [
Actually int("3.14") does not round. int(3.14) does.
On Friday, 11 October 2013 20:43:54 UTC-5, Massimo Di Pierro wrote:
>
> I am adding the +- but we cannot use int because int("3.14") would round.
>
> Anyway, I agree this can be rewritten better. Feel free to post your patch
> on google code o
I am adding the +- but we cannot use int because int("3.14") would round.
Anyway, I agree this can be rewritten better. Feel free to post your patch
on google code or as a github pull request. Thanks.
Massimo
On Friday, 11 October 2013 20:05:29 UTC-5, Stefan Pochmann wrote:
>
> It's better, but
It's better, but...
Outside character classes, the "-" is not a metacharacter and thus doesn't
need a backslash. So it could/should be:
re.compile('^-?\d+$')
You might want to accept a plus sign like in "+43" (Python's int(...) does
accept it), so:
re.compile('^[-+]?\d+$')
Or don't reinvent Py
g. fixed. Thanks for checking it. Please check again.
On Friday, 11 October 2013 17:16:59 UTC-5, Stefan Pochmann wrote:
>
> Thanks. And I'm actually relieved, the 100 digits allowance had made me
> worried about speed. However, I think you now reject all negative numbers,
> because:
>
> >>>
Thanks. And I'm actually relieved, the 100 digits allowance had made me
worried about speed. However, I think you now reject all negative numbers,
because:
>>> str(-42).isdigit()
False
None of the many examples (and thus maybe none of your tests? don't know
the system well yet) try negative nu
It is a bug in validator with numbers where int(float(x))!=int(x).
I no fixed it in trunk. There may still be problems with the fact that this
number is so large that may not be store in a database integer and requires
a database big-int.
I also changed the default validator for integers to be
9 matches
Mail list logo