Python Dictionary Comment Out a Line not Working
<p>I have a python dictionary that I import from another script. For example here is the dictionary that is in another script and loaded in:</p>

<pre><code>def Log():
    LogD = {
           'Key': [0, 1, 2],
           'Key2': [0, 1, 2],
           'Key3': [0, 1, 2], # and so on for about 100 records
          }
    return LogD
</code></pre>

<p>And here is the line loading it in:</p>

<pre><code>sys.path.append(r'C:/Whatever')
import Log
LogD = Log.Log()
</code></pre>

<p>I import it into my other script do some stuff with it and whatever. I also have a module that comments our a line in the dictionary if I want it to be deleted (ignored). That module finds the line and adds a <strong># comment</strong> to the line in the dictionary like so:</p>

<pre><code>def Log():
    LogD = {
           'Key': [0, 1, 2],
           #'Key2': [0, 1, 2],
           'Key3': [0, 1, 2], # and so on for about 100 records
          }
    return LogD
</code></pre>

<p>But when I reload the dictionary module, the commented line still appears in the dictionary. No idea why, if I don't load the dictionary as a module and include it in my running script the comment works fine. Any ideas?</p>

<p>So since no one answered this I have figured it out. Props goes to someone who commented about PYC not indexing correctly. So I added a </p>

<pre><code>os.remove(whatever.pyc) 
</code></pre>

<p>after I edit my dictionary and everything works great.</p>

python dictionary comments