The following works for me with Python 2.7.5 and your .ini file, so I can't reproduce the problem. Have I missed something?
Note: You're opening a file called sessions.ini
but your question shows it under a heading that says session.ini
-- without the 's'
. That might be the cause...
from configobj import ConfigObj
session = ConfigObj("sessions.ini", raise_errors=True)
def Session():
for item in session:
print(item)
Session()
Output:
Session 1
Session 2