[web2py] Re: Issues with integers

2013-10-11 Thread Massimo Di Pierro
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

[web2py] Re: Issues with integers

2013-10-11 Thread Stefan Pochmann
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

[web2py] Re: Issues with integers

2013-10-11 Thread Stefan Pochmann
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 [

[web2py] Re: Issues with integers

2013-10-11 Thread Massimo Di Pierro
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

[web2py] Re: Issues with integers

2013-10-11 Thread Massimo Di Pierro
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

[web2py] Re: Issues with integers

2013-10-11 Thread Stefan Pochmann
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

[web2py] Re: Issues with integers

2013-10-11 Thread Massimo Di Pierro
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: > > >>>

[web2py] Re: Issues with integers

2013-10-11 Thread Stefan Pochmann
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

[web2py] Re: Issues with integers

2013-10-11 Thread Massimo Di Pierro
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