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
  Need to replace a string with a file (HTML file) tester_V 1 762 Aug-30-2023, 03:42 AM
Last Post: Larz60+
  Determine if keyboard interrupt versus SIGINT trapped? Jibunnokage 5 1,776 Sep-30-2022, 06:54 AM
Last Post: Gribouillis
  Updating a config file [solved] ebolisa 8 2,577 Nov-04-2021, 10:20 AM
Last Post: Gribouillis
  Is there a library for recursive object creation using config objects johsmi96 0 1,843 May-03-2021, 08:09 PM
Last Post: johsmi96
  help with pytesseract.image_to_string(savedImage, config='--psm 11')iamge to string korenron 0 2,694 Apr-29-2021, 10:08 AM
Last Post: korenron
  Config file update Olivier74 0 1,474 Aug-18-2020, 03:36 PM
Last Post: Olivier74
  Wsgiref versus Requisitions JohnnyCoffee 1 1,627 Jun-14-2020, 05:15 PM
Last Post: Larz60+
  What is the best way to set application-wide config values? ajorona 1 1,910 May-07-2020, 05:03 PM
Last Post: buran
  Writing list as a file, then reading that file as a list Zoastria_Balnala 3 2,592 Oct-17-2019, 07:54 PM
Last Post: Zoastria_Balnala
  logging: child module unable to get parent config jerryxiao 3 3,362 Apr-09-2019, 04:17 AM
Last Post: jerryxiao

Forum Jump:

User Panel Messages

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