0

For instance, when I run in a python's top-level program file, I can use __name__ to get the string "__main__", but how do I get the current list of toplevel global variables?

polar9527
  • 488
  • 4
  • 18

1 Answers1

2

You might want to have a look at this thread: Viewing all defined variables

Quoting the best answer:

dir() will give you the list of in scope variables

globals() will give you a dictionary of global variables

locals() will give you a dictionary of local variables

Community
  • 1
  • 1
turtle
  • 126
  • 2
  • 10