Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 4171

Confusion about configparser Python module

$
0
0

Hello,

I need to both read and write settings to an INI file. This is trivial using the standard configparser module in Python. I see that there is a rs.GetSettings function but no corresponding rs.WriteSettings so that direction won’t work.

I tried import configparser as I would in Python but that is not available.

After some searching there is a ConfigParser module available (with different capitalization) but this does not behave the way the standard module does.

Sample file:

[Project]
Project Name = not defined.

Simplest script:

import ConfigParser
import sys

Filename = ‘C:/Temp/RhinoParameterFile.ini’
Parser = ConfigParser.ConfigParser()
Parser.read(Filename)
ProjectName = Parser[‘Project’][‘Project Name’]

Error message:

Message: ‘instance’ object has no attribute ‘getitem

Traceback:
line 7, in , “C:\Users\henry\Documents\Shape Fidelity\Rhino Not Project Specific\ConfigFileTest.py”

It is very frustrating when the most basic Python things don’t work. What is the intended solution for reading and writing INI files?

Thanks for your help/

4 posts - 4 participants

Read full topic


Viewing all articles
Browse latest Browse all 4171

Latest Images

Trending Articles



Latest Images