Hi Colin,

The problem with 'S' is that it is a singleton factory:

In [8]: sympify('S.Zero')
Out[8]: 0

In [9]: sympify('S.One')
Out[9]: 1

So sympify('S*x') can't work:

In [10]: sympify('S')
Out[10]: S

In [11]: type(_)
Out[11]: <type 'instance'>

For the similar reason sympify('lambda') does not work:

In [13]: sympify('lambda x: x')
Out[13]: Lambda(x, x)

In [14]: sympify('lambda')
SympifyError: Sympify of expression 'lambda' failed, because of
exception being raised:
SyntaxError: unexpected EOF while parsing (line 1)

Our parser should be more intelligent in those cases.

Mateusz

2008/4/1, Colin Gillespie <[EMAIL PROTECTED]>:
>
>  I've just found out that it's not 'E' that's causing the problem, it's
>  'S'.
>
>  sympify('S') #works
>  sympify('S*X') #doesn't work
>
>  Cheers
>
>
>  Colin
>
>
>  On Mar 31, 5:29 pm, Colin Gillespie <[EMAIL PROTECTED]> wrote:
>  > Dear All,
>  >
>  > I suspect that sympify is getting confused by python's builtin lambda
>  > and E
>  >
>  > So are the following examples bugs? If not, should the documentation
>  > be updated with a warning?
>  >
>  > >>> sympify('S*lambda')
>  >
>  > Traceback (most recent call last):
>  >   File "<stdin>", line 1, in ?
>  >   File "/pythonModules/lib/python2.4/site-packages/sympy-0.5.13_hg-
>  > py2.4.egg/sympy/core/sympify.py", line 127, in sympify
>  >     raise SympifyError(a, exc)
>  > sympy.core.sympify.SympifyError: Sympify of expression 'S*lambda'
>  > failed, because of exception being raised:
>  > SyntaxError: unexpected EOF while parsing (line 1)
>  >
>  > and
>  >
>  > >>> sympify('S*E')
>  >
>  > Traceback (most recent call last):
>  >   File "<stdin>", line 1, in ?
>  >   File "/data/ncsg3/pythonModules/lib/python2.4/site-packages/
>  > sympy-0.5.13_hg-py 2.4.egg/sympy/core/sympify.py", line 127, in
>  > sympify
>  >     raise SympifyError(a, exc)
>  > sympy.core.sympify.SympifyError: Sympify of expression 'S*E' failed,
>  > because of exception being raised:
>  > TypeError: unsupported operand type(s) for *: 'instance' and 'Exp1'
>  >
>  > Cheers
>  >
>  > Colin
>  >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to sympy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sympy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to