What does “…locals() or globals() introspection…” mean?

Please prove to me that “… it lead to issues with garbage collection, introduce security vulnerabilities and create thread safety concerns”.

I won’t be moving beyond Python.

What do you mean by “…domain-specific…”!


Sent from my iPhone.

On 28 Jun 2025, at 07:26, Sangyub Lee <sylee...@gmail.com> wrote:

I don't think we should add such functionality to the library. I would not use locals() or globals() introspection in library because it lead to issues with garbage collection, introduce security vulnerabilities, and create thread safety concerns.

I think you would need to move beyond Python and use a different domain-specific language or user interface to implement such functionality in a secure way. I suggest consulting with experienced software engineers or IT agencies to implement that approach.

On Wednesday, June 25, 2025 at 8:17:49 PM UTC+2 stephen.j...@gmail.com wrote:
My “use case” is that suppose you are executing Python code in the Mac terminal application to test out some code and you lose track of what variables you have created and you want to delete some or all of them to start over.

A function which lists all the created variables would be useful so you can delete them all and start over. A very basic function.

Sent from my iPhone.

> On 25 Jun 2025, at 17:46, Aaron Meurer <asme...@gmail.com> wrote:
>
> What is your use-case for such a function? In most cases if you are
> writing a script you know what symbols are defined because you have
> defined them all statically somewhere, so there's no need to
> programmatically get a list of them.
>
> Aaron Meurer
>
>> On Mon, Jun 23, 2025 at 9:14 AM Stephen Learmonth
>> <stephen.j...@gmail.com> wrote:
>>
>> 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.
>>
>> --
>> 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/c41df7a9-b27c-4e81-9fcd-85a52789b4e6n%40googlegroups.com.
>
> --
> 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/CAKgW%3D6%2B%2B_feNU%3D1psGQ1H7PapFHO67DtaqHKW8PiR59iZmrRDA%40mail.gmail.com.

--
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/f0234176-abe1-4451-a6bd-9c58bb35bb06n%40googlegroups.com.

--
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/1F182015-66E7-49AB-8702-3C98BA55CC3D%40gmail.com.

Reply via email to