Python Forum
list of user's variables in the interpreter
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
list of user's variables in the interpreter
#5
If you only want the names in the main namespace you can use
# file ud.py
def u():
    import __main__
    return [w for w in dir(__main__) if w.strip('__') == w]
Then
>>> spam = 'eggs'
>>> ham = 3
>>> import ud
>>> ud.u()
['ham', 'spam', 'ud']
Reply


Messages In This Thread
RE: list of user's variables in the interpreter - by Gribouillis - Jan-21-2018, 10:07 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Advancing Through Variables In A List knight2000 0 583 May-13-2023, 03:30 AM
Last Post: knight2000
  user input values into list of lists tauros73 3 1,246 Dec-29-2022, 05:54 PM
Last Post: deanhystad
  functional LEDs in an array or list? // RPi user Doczu 5 1,852 Aug-23-2022, 05:37 PM
Last Post: Yoriz
  User-defined function to reset variables? Mark17 3 1,824 May-25-2022, 07:22 PM
Last Post: Gribouillis
  WHILE Loop - constant variables NOT working with user input boundaries C0D3R 4 1,639 Apr-05-2022, 06:18 AM
Last Post: C0D3R
  Setting permanent user variables in Windows coder420 2 1,521 Jan-04-2022, 10:42 AM
Last Post: Larz60+
  Looking for a way to loop until user enters from a list? PythonW19 7 3,630 Mar-21-2021, 08:56 PM
Last Post: PythonW19
  User input/picking from a list AnunnakiKungFu 2 2,448 Feb-27-2021, 12:10 AM
Last Post: BashBedlam
Question Reset list if user regrets Gilush 1 2,162 Dec-05-2020, 10:55 AM
Last Post: Gilush
  Converting list to variables Palves 1 1,870 Sep-18-2020, 05:43 PM
Last Post: stullis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020