Question

Edit:
The accompanying code had a few bugs that were otherwise unrelated to the question as titled. The answer is simple enough, so I'm eliminating the irrelevant code so that the question, as asked in the title, and answer are more clearly intelligible to those searching for such things. Thanks to everyone who took the time to read the code and give me some feedback!

Original question, abridged: I seem to be having trouble when my Python script tries to access the dict entry '"__main__":', which is keyed by '__name__ =='. Is my problem related to use of these strings as variables, or is it more likely that my script is failing elsewhere? (SPOILER: My algorithm was wrong.)

Was it helpful?

Solution

Both '__name__' and '==' can serve as the key of dictionary:

>>> d = {'__name__':1, '==':2}
>>> d['__name__']
1
>>> d['==']
2
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top