Python Forum

Full Version: Config file entry as list versus string?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm writing an application with a configuration file that contains a regex expression, such as "KEY=(\w+)" which will extract the first word (in this case FRED) in an expression such as "KEY=FRED ETHEL". This the entry in the config file is:

RULE = KEY=(\w+)

The input files I'm interpreting are very highly structured, so the keys are always in a specific format.
So, it may be there are multiple keys, such as "KEY1=FRED ETHEL" & "KEY2=LUCY RICKY", and to get just the girls names, I'd set the RULE as so:

RULE = ["KEY1=\w+\s(\w+)", "KEY2=(\w+)"]

However, if I use the config parser to read that in, it's interpreted as type=str and not as type=list. Does anyone know of a clever way to have that value interpreted as a list, rather than a string, as appropriate? ./Taras
Can you post your code?
Do you need to use a configuration file format like this? Are you writing your own? If you need collections like lists, would YAML be appropriate?