Python Forum
Config file entry as list versus string?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Config file entry as list versus string?
#1
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
Reply
#2
Can you post your code?
Reply
#3
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?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Entry field random pull from list, each return own line Bear1981 6 712 Feb-25-2025, 06:09 AM
Last Post: Pedroski55
  Applications config files / Best practices aecordoba 2 1,825 Oct-23-2024, 12:56 PM
Last Post: aecordoba
  Need to replace a string with a file (HTML file) tester_V 1 1,865 Aug-30-2023, 03:42 AM
Last Post: Larz60+
  Determine if keyboard interrupt versus SIGINT trapped? Jibunnokage 5 3,472 Sep-30-2022, 06:54 AM
Last Post: Gribouillis
  Updating a config file [solved] ebolisa 8 3,950 Nov-04-2021, 10:20 AM
Last Post: Gribouillis
  Is there a library for recursive object creation using config objects johsmi96 0 2,320 May-03-2021, 08:09 PM
Last Post: johsmi96
  help with pytesseract.image_to_string(savedImage, config='--psm 11')iamge to string korenron 0 3,443 Apr-29-2021, 10:08 AM
Last Post: korenron
  Config file update Olivier74 0 1,937 Aug-18-2020, 03:36 PM
Last Post: Olivier74
  Wsgiref versus Requisitions JohnnyCoffee 1 2,229 Jun-14-2020, 05:15 PM
Last Post: Larz60+
  What is the best way to set application-wide config values? ajorona 1 2,556 May-07-2020, 05:03 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020