Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

On trying to print the value from config.ini i am getting value as None.

I have created a config.ini file

[Section] gfd_ip_address = 10.209.114.81 port = 80 application_no = 3 resourceSet_name = ['resourceset1','resourceset2','resourceset3'] server_name = cme.gfdlab1.com source_url = http://10.209.51.149/2MB;http://10.209.51.149/2MB

and i trying to access these values from config.py

import ConfigParser

def ConfigSectionMap(Section):

Config = ConfigParser.ConfigParser()
file = open("C:\D\python\config.ini", 'r')
content = file.read()

gfd_ip_address = ConfigSectionMap("gfd_ip_address") port = ConfigSectionMap("port") application_no = ConfigSectionMap("application_no")

print "The gfd_ip_address is {} , port is {} and application_no is {}" .format(gfd_ip_address,port,application_no)

output : The gfd_ip_address is None , port is None and application_no is None

can anyone please help me with this?