I don’t see SaveSettings in RhinoScriptSyntax - is there a way to read/write an .ini file in a similar way in Python?
thanks,
–jarek
I don’t see SaveSettings in RhinoScriptSyntax - is there a way to read/write an .ini file in a similar way in Python?
thanks,
–jarek
Hi Jarek,
I’ve been using ConfigParser without issues so far:
Let me know if you don’t get it to work, I might have pruned my custom code a little too much
import ConfigParser
def read_ini_file(filepath):
cnfg = ConfigParser.ConfigParser()
cnfg.read(filepath)
config_dict = {}
for section in cnfg.sections():
section_dict = {}
options = cnfg.options(section)
for option in options:
raw_value = cnfg.get(section, option)
value = raw_value.decode("utf-8")#optional not essential
section_dict[option] = value
config_dict[section] = section_dict
return config_dict
-Willem
Thanks Willem! I will give it a shot and try to see if I can also make it write ini files…
Ah yes the writing part… I only use it to fetch configuration files so never implemented writing out dictionaries.
Actually that’s good - an excuse for me to practice and learn
Found this for starters: https://docs.python.org/2/library/configparser.html#examples
–jarek