I have very simple problem I want to print everything that's inside session.ini
But it doesn't let me the output is: >> {}
Does somebody have a trick how to print everything inside the session.ini
inside: session.ini
[Session 1]
Data = "session_1.db"
[Session 2]
Data = "session_1.db"
The code:
session = ConfigObj("sessions.ini")
def Session():
for item in session:
print(item)
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