Using str as arg

45 views
Skip to first unread message

Paul Royik

unread,
Dec 6, 2024, 1:14:53 PM12/6/24
to sympy
For consistency I need to define a class that extends the Basic class, but whose args can contain str.

What is the best way to do this?

Aaron Meurer

unread,
Dec 7, 2024, 6:07:46 PM12/7/24
to sy...@googlegroups.com
You can use sympy.core.symbol.Str. But be aware that sympify() will
still convert strings into Symbol.

Aaron Meurer

On Fri, Dec 6, 2024 at 11:14 AM Paul Royik <distan...@gmail.com> wrote:
>
> For consistency I need to define a class that extends the Basic class, but whose args can contain str.
>
> What is the best way to do this?
>
> --
> 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 sympy+un...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/sympy/a1599f30-e192-45dd-a632-1b0b626219e8n%40googlegroups.com.

Sangyub Lee

unread,
Dec 8, 2024, 2:12:37 PM12/8/24
to sympy
There is wrapper class "Str" to convert string to sympy objects, that can be used for args

https://github.com/sympy/sympy/blob/e53690af7e57eeef7e8c6dea1521a4dc0024cf95/sympy/core/symbol.py#L26

But generally, it is fine to use "Symbol" because there is often no semantical difference between symbol and strings, for use of names.
but adding/multiplying the symbols doesn't make sense for such usage.

Paul Royik

unread,
Dec 8, 2024, 6:24:11 PM12/8/24
to sympy
Thank you very much for your help!
Reply all
Reply to author
Forward
0 new messages