OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

What is this Python list containing all tokens from my code?

  • Thread starter Thread starter Neil
  • Start date Start date
N

Neil

Guest
If I run this code in Python 3.10:

Code:
import gc


def main():
    a = 23764723
    ref = gc.get_referrers(a)[0]
    print(ref)


if __name__ == "__main__":
    main()

I get the following output:

Code:
['gc', 'main', 'a', 23764723, 'ref', 'gc', 'get_referrers', 'a', 0, 'print', 'ref', '__main__', '__name__', 'main']

What is this list, that seems to contain all of the literals(?) from my code? Is there an explanation in the Python docs anywhere?
<p>If I run this code in Python 3.10:</p>
<pre><code>import gc


def main():
a = 23764723
ref = gc.get_referrers(a)[0]
print(ref)


if __name__ == "__main__":
main()

</code></pre>
<p>I get the following output:</p>
<pre><code>['gc', 'main', 'a', 23764723, 'ref', 'gc', 'get_referrers', 'a', 0, 'print', 'ref', '__main__', '__name__', 'main']
</code></pre>
<p>What <em>is</em> this list, that seems to contain all of the literals(?) from my code? Is there an explanation in the Python docs anywhere?</p>
 
Top