- publishing free software manuals
Python Language Reference Manual
by Guido van Rossum and Fred L. Drake, Jr.
Paperback (6"x9"), 120 pages
ISBN 0954161785
RRP £12.95 ($19.95)

Sales of this book support the Python Software Foundation! Get a printed copy>>>

2.4.4 Integer and long integer literals

Integer and long integer literals are described by the following lexical definitions:

longinteger integer ( "l" | "L" )
integer decimalinteger
| octinteger | hexinteger
decimalinteger nonzerodigit digit* | "0"
octinteger "0" octdigit+
hexinteger "0" ("x" | "X") hexdigit+
nonzerodigit "1"..."9"
octdigit "0"..."7"
hexdigit digit | "a"..."f" | "A"..."F"

Although both lower case ‘l’ and upper case ‘L’ are allowed as suffix for long integers, it is strongly recommended to always use ‘L’, since the letter ‘l’ looks too much like the digit ‘1’.

Plain integer literals that are greater than the largest representable plain integer (e.g., 2147483647 when using 32-bit arithmetic) are accepted as if they were long integers instead.(5) There is no limit for long integer literals apart from what can be stored in available memory.

Some examples of plain integer literals (first row) and long integer literals (second and third rows):

    7   2147483647                      0177
    3L  79228162514264337593543950336L  0377L  0x100000000L
        79228162514264337593543950336          0xdeadbeef						    
ISBN 0954161785Python Language Reference ManualSee the print edition