A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2001-February/012888.html below:

[Python-Dev] SyntaxError for illegal literals

[Python-Dev] SyntaxError for illegal literalsTim Peters tim.one@home.com
Tue, 13 Feb 2001 23:13:00 -0500
[Thomas Wouters]
> ... what is wrong (in the \x escape example) is the *value* of
> something (of the \x escape in question.) If a syntax error was
> raised, I would think something was wrong with the syntax. But
> the \x is placed in the right spot, inside a string literal. The
> string literal itself is placed right. Why would it be a syntax
> error ?

Oh, why not <wink>.  The syntax of an \x escape is

    "\\" "x" hexdigit hexdigit

and to call something that doesn't match that syntax a SyntaxError isn't
much of a stretch.  Neither is calling it a ValueError.

[Guido]
> Another solution (borrowing from C): automatically promote int
> literals to long if they can't be evaluated as ints.

Yes!  The user-visible distinction between ints and longs causes more
problems than it solves.  Would also get us one step closer to punting the
incomprehensible "because the grammar implies it" answer to the FAQlet:

    Yo, Phyton d00dz!  What's up with this?

    >>> x = "-2147483648"
    >>> int(x)
    -2147483648
    >>> eval(x)
    Traceback (most recent call last):
      File "<stdin>", line 1, in ?
    OverflowError: integer literal too large
    >>>




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4