title: Python - read from file skip lines starts with #
body: <p>Try to read file and make a dictionary from lines, skippipng lines starts with # symbol</p>
  
  <p>file example:</p>
  
  <pre><code>param1=val1
  # here is comment
  </code></pre>
  
  <p>My function:</p>
  
  <pre><code>def readFromFile(name):
      config = {}
      with open(name, "r") as f:         
          for line in f.readlines():
              li=line.lstrip()
              if not li.startswith("#"):
                  config[line.split('=')[0]] = line.split('=')[1].strip()
      return config
  </code></pre>
  
  <p>I get list index out of range error</p>
  
  <p>But!
  if i try to skip lines starts with, for example, symbol "h" - function works well...</p>