Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > why does Configparser change names to lowercase ?

Reply
Thread Tools

why does Configparser change names to lowercase ?

 
 
stef mientki
Guest
Posts: n/a
 
      09-14-2007
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


 
Reply With Quote
 
 
 
 
James Stroud
Guest
Posts: n/a
 
      09-14-2007
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
 
Reply With Quote
 
 
 
 
Rob Wolfe
Guest
Posts: n/a
 
      09-14-2007
stef mientki <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: CamelCase vs. all-lowercase package names dieter Python 0 02-02-2013 08:03 AM
ConfigParser: Can I read(ConfigParser.get()) a configuration file anduse it to call a funciton? jamitwidme@gmail.com Python 3 06-26-2008 08:01 PM
RE: why does Configparser change names to lowercase ? Python 0 09-18-2007 02:17 AM
lowercase class names, eg., qtgui ? (PyQt4) Glen Python 2 04-26-2007 02:36 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM



Advertisments