Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (47.6k points)

I'm currently working on computation in python shell. What I want to have is Matlab style list out where you can see all the variables that have been defined up to a point (so I know which names I've used, their values and such).

Is there a way, and how can I do that?

1 Answer

0 votes
by (106k points)

If you want to View all defined variables you can use the below-mentioned way:

  • You can use dir()  function it will give you the list of in-scope variables:

  • You have another option of using globals() which will give you a dictionary of global variables

  • The third option you have is to use locals() function which will give you a dictionary of local variables

Related questions

0 votes
2 answers
asked Jul 13, 2019 in Python by Sammy (47.6k points)
0 votes
1 answer
0 votes
1 answer

Browse Categories

...