[Python-Dev] Behavoir question.

Calvin Spealman ironfroggy at gmail.com
Wed Nov 16 08:16:49 CET 2005


On 11/15/05, Scott David Daniels <Scott.Daniels at acm.org> wrote:
> Since I am fiddling with int/long conversions to/from string:
>
> Is the current behavior intentional (or mandatory?):
>
>      v = int('       55555555555555555555555555555555555555555       ')
> works, but:
>      v = int('       55555555555555555555555555555555555555555L      ')
> fails.
>
> --Scott David Daniels
> Scott.Daniels at Acm.Org

int(s) works where s is a string representing a number. 10L does not
represent a number directly, but is Python syntax for making an
integer constant a long, and not an int. (Consider that both are
representations of mathematical integers, tho in python we only call
one of them an integer by terminology).

So, what you're asking is like if list('[1,2]') returned [1,2]. If you
need this functionality, maybe you need a regex match and expr().


More information about the Python-Dev mailing list