[IPython-user] Parsing issue (maybe).
Robert Kern
robert.kern at gmail.com
Thu Jan 12 14:38:32 CST 2006
Andrea Riciputi wrote:
> Hi all,
> I've a problem here with ipython 0.6.15. I don't know if the new
> version (0.7.0) still exhibits the same problem though. Here it is
> the problem. I've defined a class to mimick mathematical functions
> and in that class I've defined the special method __and__ to check if
> 2 functions have the same dimensionality. Here it is a meaningfull
> excerpt:
>
> In [1]: import Functions
>
> In [2]: x = Numeric.arange(10)
>
> In [3]: y = Numeric.arange(5)
>
> In [4]: z1 = x[:,Numeric.NewAxis] + y
>
> In [5]: z2 = x[:,Numeric.NewAxis] - y
>
> In [6]: foo = Functions.Function([x,y], z1)
>
> In [7]: bar = Functions.Function([x,y], z2)
>
> In [8]: foo & bar
> ------> foo(& bar)
> ------------------------------------------------------------
> File "<console>", line 1
> foo(& bar)
> ^
> SyntaxError: invalid syntax
Turn off %autocall. With %autocall on, ipython recognizes the first token as
referring to a callable (I presume Function's are callable), and so it tries to
transform the command into a function call. Of course, this doesn't work in this
case.
I usually have %autocall off for this reason.
--
Robert Kern
robert.kern at gmail.com
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
More information about the IPython-user
mailing list