[Python-Dev] Revamping Python's Numeric Model

Thomas Wouters thomas@xs4all.net
Sat, 4 Nov 2000 15:08:43 +0100

On Sat, Nov 04, 2000 at 08:19:13PM +0200, Moshe Zadka wrote:

> > There's one problem though: how would you call these on
> > numeric literals ? ... 1.2.isreal() ?!

> you use parens:
> (1.2).isreal()

Why ? There is exactly no problem with this example :)

>>> 1.2.isreal()
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: 'float' object has no attribute 'isreal'

If float objects had attributes, it would already work. The real problem
isn't with floats, but with nonfloats:

>>> 1.isreal()
  File "<stdin>", line 1
SyntaxError: invalid syntax

And the limitation is just the parser, currently. Whether we want to allow
that syntax is something that will have to be figured out. And the parser
would have to be fixed (either rewritten into at least an LL(2) parser, or
the metagrammar hacked so that 'NUMBER' doesn't eat the . after a number if
it isn't followed by another number or whitespace.) (At least IMHO, this
isn't an insurmountable problem, or even a medium-sized problem. It was just
never necessary to fix it.)

Thomas Wouters <thomas@xs4all.net>

Hi! I'm a .signature virus! copy me into your .signature file to help me spread!