[Numpy-discussion] Possible new multiplication operators for Python

Andrew Dalke dalke@dalkescientific....
Sun Aug 17 14:33:33 CDT 2008


Gaël Varoquaux wrote:
> Anybody care for '.*'?

That's border-line case, and probably on the bad
idea side because 1.*2 already means something in
normal Python.  If added there would be a difference
between
   1.*2
and
   1 .*2

This problem already exists.  Consider

 >>> 1 .__str__()
'1'
 >>> 1.__str__()
   File "<stdin>", line 1
     1.__str__()
             ^
SyntaxError: invalid syntax
 >>> 1..__str__()
'1.0'
 >>>

but it doesn't come up much because it's extremely
rare for anyone to call numerical methods directly.

Whereas people already write things like "2*x" so
writing "2.*x" to mean piecewise but actually get
object-wise seems likely.

This is why I think being able to write experimental
support for new syntax, and gain experience about
it's advantages and disadvantages, could be useful
and could provide additional sway for python-dev folks.


				Andrew
				dalke@dalkescientific.com




More information about the Numpy-discussion mailing list