Re: why does Configparser change names to lowercase ?
On Friday 14 September 2007 12:21, stef mientki wrote: Why does Configparser change names to lowercase ? As Python is case sensitive (which btw I don't like at all ;-) but now when really need the casesensitivity, because it handles about names which should be recognized by human, it changes everything to lowercase thanks, Stef Mientki According to the ConfigParser docs: All option names used in interpolation will be passed through the optionxform() method just like any other option name reference. For example, using the default implementation of optionxform() (which converts option names to lower case), the values foo %(bar)s and foo %(BAR)s are equivalent. So, it seems it would be trivial so sublcass ConfigParser, and reimplement optionxform() Hope that helps. j -- Joshua Kugler Lead System Admin -- Senior Programmer http://www.eeinternet.com PGP Key: http://pgp.mit.edu/ ID 0xDB26D7CE -- http://mail.python.org/mailman/listinfo/python-list
RE: why does Configparser change names to lowercase ?
This works ... Cf=ConfigParser.ConfigParser() Cf.optionxform=str ... Blinston. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Joshua J. Kugler Sent: Tuesday, September 18, 2007 3:44 AM To: python-list@python.org Subject: Re: why does Configparser change names to lowercase ? On Friday 14 September 2007 12:21, stef mientki wrote: Why does Configparser change names to lowercase ? As Python is case sensitive (which btw I don't like at all ;-) but now when really need the casesensitivity, because it handles about names which should be recognized by human, it changes everything to lowercase thanks, Stef Mientki According to the ConfigParser docs: All option names used in interpolation will be passed through the optionxform() method just like any other option name reference. For example, using the default implementation of optionxform() (which converts option names to lower case), the values foo %(bar)s and foo %(BAR)s are equivalent. So, it seems it would be trivial so sublcass ConfigParser, and reimplement optionxform() Hope that helps. j -- Joshua Kugler Lead System Admin -- Senior Programmer http://www.eeinternet.com PGP Key: http://pgp.mit.edu/ ID 0xDB26D7CE -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
why does Configparser change names to lowercase ?
hello, Why does Configparser change names to lowercase ? As Python is case sensitive (which btw I don't like at all ;-) but now when really need the casesensitivity, because it handles about names which should be recognized by human, it changes everything to lowercase thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list
Re: why does Configparser change names to lowercase ?
stef mientki wrote: hello, Why does Configparser change names to lowercase ? Because it is an annoying module and should be tossed for something better? Try this instead (and never look back): http://www.voidspace.org.uk/python/configobj.html As Python is case sensitive (which btw I don't like at all ;-) but now when really need the casesensitivity, because it handles about names which should be recognized by human, it changes everything to lowercase So you are saying the case sensitivity is a good thing--or maybe you are still running Mac System 7 on your CSIIsi marveling at the wonders of HFS? James -- http://mail.python.org/mailman/listinfo/python-list
Re: why does Configparser change names to lowercase ?
stef mientki [EMAIL PROTECTED] writes: hello, Why does Configparser change names to lowercase ? As Python is case sensitive (which btw I don't like at all ;-) but now when really need the casesensitivity, because it handles about names which should be recognized by human, it changes everything to lowercase I don't know why, but I know how to change it and I found the solution here: http://docs.python.org/lib/RawConfigParser-objects.html You need to change the implementation of method `optionxform`, e.g.: # config [section1] option1=item1 Option2=item2 option2=item3 # cfg.py from ConfigParser import ConfigParser config = ConfigParser() config.optionxform = str config.read('config') print config.get('section1', 'option1') print config.get('section1', 'Option2') print config.options('section1') HTH, Rob -- http://mail.python.org/mailman/listinfo/python-list