When creating list or generator comprehensions in CPython 3 you might/might not know that the iterator that is being iterated upon is stored in the name .0. This is of course inaccessible by normal means since you can't have . in a name in Python, but it can be accessed using locals() like this:
>>> [locals()['.0'] for _ in [1]]
[<tuple_iterator object at 0x7f9489e85ee0>]
I was curious where this name originates in the CPython source code and also if similar "hidden" names like these can be found anywhere else. The only other I can think of is _ which refers to the last printed value when using Python in interactive mode. I was however having trouble navigating the CPython source code and so I ask you if anyone knows:
- Where does this name come from? (what file and line n/o, preferably for CPython 3.10)
- Are there any other similar "hidden" names? (why
.0? can there be.1?)
Edit:
After looking at the question linked by @sj95126 I checked symtable.c and found this which is responsible for creating all .n names where n is an integer. It is only ever called with zero as an argument within symtable.c which suggests that it will also never be a non-zero value in practice in whichever function is actually responsible for compiling the names. But this is as mentioned not the actual function and symtable.c has had errors before as also mentioned in one of the answers to the question linked above. So I still wonder where this is actually defined, and what any other "hidden" names exist.