How can we see the Symbol-Table of a python source code?
I mean, Python makes a symbol table for each program before actually running it. So my question is how can I get that symbol-table as output?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you are asking about the symbol table that is used when generating bytecode, take a look at the
symtablemodule. Also, these two articles by Eli Bendersky are fascinating, and very detailed:Python Internals: Symbol tables, part 1
Python Internals: Symbol tables, part 2
In part 2, he details a function that can print out a description of a symtable, but it seems to have been written for Python 3. Here’s a version for Python 2.x: