Thanks Krishnav,

It would have been really useful if Sympy just had a function like 
list_symbols() oir something from the start.

It''s such a basic thing to want to be able to do!

Stephen

On Monday, 23 June 2025 at 16:00:38 UTC+1 bajoria...@gmail.com wrote:

> Hi Stephen,
>
> If you want to list all sympy symbols that you have created in a Python 
> script, one straightforward way is to use Python’s built-in globals() to 
> scan the current namespace and check for instances of sympy.Symbol.
>
> Here's a simple example to illustrate:
>
> >>> from sympy import Symbol>>> from sympy.abc import a, b, c
> >>> x = Symbol('x')
> >>> y = Symbol('y')
> >>> z = 3  # this is not a SymPy symbol
> >>> symbols_used = [name for name, obj in globals().items() if 
> >>> isinstance(obj, Symbol)]>>> print("Symbols used :", symbols_used)
>
> This would output:
>
> Symbols used : ['a', 'b', 'c', 'x', 'y']
>
> But do let me know if you are looking for something more specific. Happy 
> to help further!
>
> Best regards,
>
> Krishnav Bajoria.
>
> On Mon, Jun 23, 2025 at 8:07 PM Stephen Learmonth <stephen.j...@gmail.com> 
> wrote:
>
>> How do I list ALL sympy symbols created in a Python script? 
>>
>> -- 
>> 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/2f682bea-f462-4188-9873-82c9ebafe889n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/sympy/2f682bea-f462-4188-9873-82c9ebafe889n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/sympy/c41df7a9-b27c-4e81-9fcd-85a52789b4e6n%40googlegroups.com.

Reply via email to