|
From: Michael F. <fuz...@vo...> - 2011-02-24 14:22:13
|
On 24/02/2011 13:50, Anton Hughes wrote:
> Hi
> Im trying to use ConfigObj but am getting the following error. And I
> have know idea what I am doing wrong. Anyone can help?
>
> from configobj import ConfigObj
> config = ConfigObj('c:\temp\config.ini')
This line probably doesn't do what you expect. In Python the backslash
is an escape character in strings and "\t" is a tab. Try this instead:
config = ConfigObj(r'c:\temp\config.ini')
The "r" makes the string raw so that backslashes are literals rather
than escape characters.
All the best,
Michael Foord
> config["som_somserver"]
> Traceback (most recent call last):
> File "<console>", line 1, in <module>
> File "build\bdist.win32\egg\configobj.py", line 567, in __getitem__
> val = dict.__getitem__(self, key)
> KeyError: 'som_somserver'
>
>
>
> Here is a copy of my config file:
> soc_source = soc_source
> retail_price = $400
> soc_source = 1
> soc_theme = 2
> soc_target = 3
> soc_folder_exist = 4
> soc_folder_temp_exist = 5
> soc_folder_backup_exist = 6
> som_somserver = 1
> som_filename=2
> som_sourcefile = 3
> som_targetfile = 4
> som_fileexist = 5
> som_file_temp_exist=6
> som_file_backup_exist=7
>
> Thanks
>
>
> ------------------------------------------------------------------------------
> Free Software Download: Index, Search& Analyze Logs and other IT data in
> Real-Time with Splunk. Collect, index and harness all the fast moving IT data
> generated by your applications, servers and devices whether physical, virtual
> or in the cloud. Deliver compliance at lower cost and gain new business
> insights. http://p.sf.net/sfu/splunk-dev2dev
>
>
> _______________________________________________
> Configobj-develop mailing list
> Con...@li...
> https://lists.sourceforge.net/lists/listinfo/configobj-develop
--
http://www.voidspace.org.uk/
May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing http://www.sqlite.org/different.html
|