Oh I see. I didn't realize you were using sympify. But I don't see anywhere
in the docs that indicates that sympify should understand how to deal with
variable names that include a period. The function that is failing is:

http://docs.sympy.org/dev/modules/parsing.html#sympy.parsing.sympy_parser.parse_expr

You can customize the parsers if you want to handle different kinds of
string input.


Jason
moorepants.info
+01 530-601-9791

On Tue, Dec 30, 2014 at 2:39 PM, Andrew Spielberg <[email protected]>
wrote:

> Hi Jason,
>
> That's true that it's an invalid character for python variables, but not
> for sympy variables.  For instance, doing:
>
> s = Symbol('base.length')
>
> works just fine.
>
> I was under the impression that sympify's inputs is treated as a string
> version of a sympy expression, *NOT* a Python expression.  This seems to
> be what the documentation implies:
> http://docs.sympy.org/dev/modules/core.html.
>
> Shouldn't this work?  I feel like either the documentation is
> misleading/ambiguous or the function is not matching the specification.
>
> Is there a workaround you would recommend that will properly parse periods
> as Symbol does?
>
> -Andy S.
>
> On Tue, Dec 30, 2014 at 1:23 AM, Jason Moore <[email protected]> wrote:
>
>> Andy,
>>
>> The period is an invalid character for Python variables. The period is
>> reserved for accessing attributes and methods of Python objects.
>>
>>
>> Jason
>> moorepants.info
>> +01 530-601-9791
>>
>> On Mon, Dec 29, 2014 at 5:48 PM, Andrew Spielberg <[email protected]>
>> wrote:
>>
>>> Hi guys,
>>>
>>> I have a variable with a period in it (say, 'base.length').  I now wish
>>> to sympify an expression, say:
>>>
>>> 2*base.length
>>>
>>> This throws an exception,
>>>
>>> AttributeError: 'Symbol' object has no attribute 'length'
>>>
>>> due to the period.  Is there a way I can have the sympify read the dot
>>> as just part of a variable name here?
>>>
>>> -Andy S.
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "sympy" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to [email protected].
>>> To post to this group, send email to [email protected].
>>> Visit this group at http://groups.google.com/group/sympy.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/sympy/CAM6e1JdM%3Dz_vcQkQo%3DLcSVO7oxznXhrVt0U2xQw5GMe8os_R1A%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/sympy/CAM6e1JdM%3Dz_vcQkQo%3DLcSVO7oxznXhrVt0U2xQw5GMe8os_R1A%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "sympy" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/sympy.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/sympy/CAP7f1AizO6eQJd4QwaUFWQssfsnDstKh1v%3DuKo74HF2xgqBL5A%40mail.gmail.com
>> <https://groups.google.com/d/msgid/sympy/CAP7f1AizO6eQJd4QwaUFWQssfsnDstKh1v%3DuKo74HF2xgqBL5A%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sympy.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/sympy/CAM6e1JdwJw52%3D%3DqKFWiSVfMstvwAOO-2vWuvfBfgeTjjp2%3DwSA%40mail.gmail.com
> <https://groups.google.com/d/msgid/sympy/CAM6e1JdwJw52%3D%3DqKFWiSVfMstvwAOO-2vWuvfBfgeTjjp2%3DwSA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAP7f1AiEbCSsoBPUZgGTSpxKJwn0r%3DUqpqKeFBVDg6_C1PBVUQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to