[Python-Dev] Symmetry arguments for API expansion (original) (raw)

Serhiy Storchaka storchaka at gmail.com
Tue Mar 13 05:02:57 EDT 2018


13.03.18 10:35, Larry Hastings пише:

On 03/12/2018 08:41 PM, Guido van Rossum wrote:

If you force me to choose between allowing hex(3.14) or 42.hex() I'll choose the latter I assume you meant (42).hex() here.  If you're also interested in changing the language to permit 42.hex(), well, color me shocked :D (For those who haven't seen this before: it's a well-known gotcha. When Python's grammar sees "42.hex()", it thinks "42." is the start of a floating-point constant.  But "42.hex" isn't a valid floating-point constant, so it throws a SyntaxError.)

"42." is a valid floating-point constant. But a floating-point constant followed by an identifier is an invalid syntax. This is the same error as in "42. hex" and "42 hex".



More information about the Python-Dev mailing list